// 因为是中文题面就偷一次懒不写题意啦QAQ

// 各种大作业然后又要期末还不知道什么时候能补题QAQ

A. 唐纳德先生和假骰子

直接模拟

#include <bits/stdc++.h>
using namespace std;
int a[6], b[6], cnt[20];
typedef long long LL;
int main() {
int p;
scanf("%d", &p);
for (int i = 0; i < 6; ++i) scanf("%d", &a[i]);
for (int i = 0; i < 6; ++i) scanf("%d", &b[i]);
for (int i = 0; i < 6; ++i) {
for (int j = 0; j < 6; ++j) {
++cnt[(a[i]+b[j]) % p];
}
}
if (p == 3) {
if (cnt[0] == 12 && cnt[1] == 12 && cnt[2] == 12) puts("YES");
else puts("NO");
}
else {
if (cnt[0] == 9 && cnt[1]==9 && cnt[2]==9 && cnt[3]==9) puts("YES");
else puts("NO");
}
return 0;
}

B. 在哈尔滨的寒风中

容易发现当棋盘大于等于\(3\times 5\)时马可以到达任何地方,其他情况分类讨论一下即可。

// 一开始不知道怎么的理解成了马步只有\(1\times 2\)而漏了\(2\times 1\),然后整个棋局中的点就分成了四类,很高兴地交了结果wa了还纳闷的半天

// 偷懒写了个dfs(?)而没有去数小的几种情况还是原谅我吧...

#include <bits/stdc++.h>
int dr[8][2] = {{-1,-2}, {-2, -1}, {-2, 1} ,{-1, 2}, {1, 2}, {2,1}, {2,-1}, {1,-2}};
using namespace std;
typedef long long LL;
LL n,m;
int c[10][10];
LL C(LL x, int) { return x * (x-1) / 2; }
void dfs(int x, int y, int col) {
c[x][y] = col;
for (int i = 0; i < 8; ++i) {
int xx = x + dr[i][0], yy = y +dr[i][1];
if (xx <= 0 || xx > n || yy <= 0 || yy > m) continue;
if (!c[xx][yy]) dfs(xx, yy, col);
}
}
int cnt[100];
int main() {
scanf("%lld%lld", &n, &m);
LL ans=0;
if (n > m) swap(n, m);
if (n == 1) ans = 0;
else if (n == 2) {
LL n1,n2,n3,n4;
n1=n2=n3=n4 = (n/2)*(m/2);
if (m&1) ++n1,++n2;
ans = C(n1,2)*2+C(n3,2)*2;
}
else if (n == 3 || n == 4) {
if (m >= 5) ans = C(n*m, 2);
else {
int tot = 0;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
if (!c[i][j]) dfs(i, j, ++tot);
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
++cnt[c[i][j]];
}
}
for (int i = 1; i <= tot; ++i) {
ans += C(cnt[i], 2);
}
}
}
else ans = C(n*m,2); printf("%lld\n", ans);
return 0;
}

C. 易位构词

按字母出现次数排个序,然后整体循环右移 (出现最多的字母出现的位数) 那么多位,然后再按下标扔回去。

很合理。

// 比赛时没做出来,一开始一直在想最大流...

// 题解还是强啊

// 注意排序的时候不仅要按次数还要按字母本身,因为目的是要让一块一块靠在一起

#include <bits/stdc++.h>
#define maxn 100010
using namespace std;
int cnt[256];
char s[maxn], ss[maxn], ans[maxn];
struct node {
char c; int p;
bool operator < (const node& nd) const {
return cnt[c] > cnt[nd.c] || (cnt[c] == cnt[nd.c] && c < nd.c);
}
}a[maxn];
int main() {
scanf("%s", s);
int n = strlen(s);
for (int i = 0; i < n; ++i) a[i] = {s[i], i}, ++cnt[s[i]];
sort(a, a+n);
char mx = a[0].c;
int i = 0;
for (; i < n; ++i) if (a[i].c != mx) break;
int num = i;
if ((num<<1) > n) puts("impossible");
else {
for (int i = 0; i < n; ++i) ss[(i+num)%n] = a[i].c;
for (int i = 0; i < n; ++i) ans[a[i].p] = ss[i];
ans[n] = '\0';
puts(ans);
}
return 0;
}

D. 唐纳德和他的数学老师

类似bzoj 1191 超级英雄Hero 二分图匹配

// 开这道题的时候过的才十个人出头,读了一遍下来觉得这题十分熟悉...

// 然后因为数组大小的问题RE了3发...

#include <bits/stdc++.h>
#define maxn 1010
using namespace std;
typedef long long LL;
int tot, prime[maxn], a[3010], n, match[1000010], ne[3010], pp;
bool used[1000010], check[maxn];
struct Edge {
int to, ne;
Edge(int _to=0, int _ne=0) : to(_to), ne(_ne) {}
}edge[3000010];
void add(int u, int v) {
edge[tot] = Edge(v, ne[u]);
ne[u] = tot++;
}
void init() {
for (int i = 2; i <= 1000; ++i) {
if (!check[i]) {
prime[pp++] = i;
}
for (int j = 0; j < pp; ++j) {
if (i * prime[j] > 1000) break;
check[i * prime[j]] = true;
if (i % prime[j] == 0) break;
}
}
}
bool find(int u) {
for (int i = ne[u]; ~i; i = edge[i].ne) {
int v = edge[i].to;
if (used[v]) continue;
used[v] = true;
if (!match[v] || find(match[v])) {
match[v] = u;
return true;
}
}
return false;
}
int main() {
init();
scanf("%d", &n); tot = 0; memset(ne, -1, sizeof ne);
for (int i = 1; i <= n; ++i) {
scanf("%d", &a[i]);
int temp = a[i];
for (int j = 0; j < pp; ++j) {
if (temp < prime[j]) break;
if (temp % prime[j] == 0) add(i, prime[j]);
while (temp % prime[j] == 0) temp /= prime[j];
}
if (temp != 1) add(i, temp);
}
for (int i = 1; i <= n; ++i) {
memset(used, 0, sizeof used);
if (!find(i)) { cout << i-1 << endl; return 0; }
}
cout << n << endl;
return 0;
}

EOJ Monthly 2017.12 A B C D的更多相关文章

  1. Gitlab一键端的安装汉化及问题解决(2017/12/14目前版本为10.2.4)

    Gitlab的安装汉化及问题解决 一.前言 Gitlab需要安装的包太TM多了,源码安装能愁死个人,一直出错,后来发现几行命令就装的真是遇到的新大陆一样... ... 装完之后感觉太简单,加了汉化补丁 ...

  2. EOJ Monthly 2019.2 题解(B、D、F)

    EOJ Monthly 2019.2 题解(B.D.F) 官方题解:https://acm.ecnu.edu.cn/blog/entry/320/ B. 解题 单测试点时限: 2.0 秒 内存限制:  ...

  3. 【2017.12.12】deepin安装U盘制作,支持 BIOS+UEFI,deepin_Recovery+Win PE

    U盘要求为 FAT32,MBR分区表 如果需要放 4GB 大文件,可以分两个分区,第一分区FAT32格式,放启动相关文件,第二个分区用 NTFS 格式,放其它资料. 最新 Win10 支持显示 U盘 ...

  4. 2017.12.21-JQuery

    作业:密码加强验证 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> & ...

  5. 2017.12.25 Mybatis物理分页插件PageHelper的使用(二)

    参考来自: 官方文档的说明:https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/HowToUse.md 上篇博客 ...

  6. [LOJ#6259]「CodePlus 2017 12 月赛」白金元首与独舞

    [LOJ#6259]「CodePlus 2017 12 月赛」白金元首与独舞 试题描述 到河北省 见斯大林 / 在月光下 你的背影 / 让我们一起跳舞吧 うそだよ~ 河北省怎么可能有 Stalin. ...

  7. java一周学习记录(2017/12/2)

    姓名:Danny                               日期:2017/12/2 周日 周一 周二 周三 周四 周五 周六 所花时间 120 150 190 150 180 28 ...

  8. 【EOJ Monthly 2018.2 (Good bye 2017)】

    23333333333333333 由于情人节要回家,所以就先只放代码了. 此题是与我胖虎过不去. [E. 出老千的 xjj] #include<cstdio> #include<c ...

  9. 2017.12.7 URAT 串口通信

    波特率就是发送二进制数据位的速率, 习惯上用 baud 表示, 即我们发送一位二进制数据的持续时间=1/baud. 在通信之前, 单片机 1 和单片机 2 首先都要明确的约定好它们之间的通信波特率, ...

随机推荐

  1. 二十四、MySQL ALTER命令

    MySQL ALTER命令 当我们需要修改数据表名或者修改数据表字段时,就需要使用到MySQL ALTER命令. 开始本章教程前让我们先创建一张表,表名为:testalter_tbl. root@ho ...

  2. 自动化运维工具——ansible安装入门(一)

    一.简介 现如今有很多运维自动化的工具,如:Ansible.Puppet.saltStack.Fabric.chef.Cfengine 1. Ansible介绍 Ansible 是由 Cobbler与 ...

  3. php下关于Cannot use a scalar value as an array的解决办法

    今天在测试php程序的时候,出现了一个错误提示:Cannot use a scalar value as an array,这个错误提示前几天也出过,当时好像稍微调了一下就好了,也没深究,今天却又出现 ...

  4. 科学计算库Numpy——数值计算

    矩阵 求和 乘积 最大值和最小值 最大值和最小值的位置 平均数 标准差 方差 限制 四舍五入

  5. 三分钟明白 Activity工作流 -- java运用

    一. 什么是工作流 以请假为例,现在大多数公司的请假流程是这样的 员工打电话(或网聊)向上级提出请假申请——上级口头同意——上级将请假记录下来——月底将请假记录上交公司——公司将请假录入电脑 采用工作 ...

  6. 自定义View/ViewGroup的步骤和实现

    1.设置属性(供XML调用) 在res目录新建attrs.xml文件 <?xml version="1.0" encoding="utf-8"?> ...

  7. OpenCV学习笔记(七) 图像金字塔 阈值 边界

    转自: OpenCV 教程 使用 图像金字塔 进行缩放 图像金字塔是视觉运用中广泛采用的一项技术.一个图像金字塔是一系列图像的集合 - 所有图像来源于同一张原始图像 - 通过梯次向下采样获得,直到达到 ...

  8. POJ 3041 Asteroids (二分图最小点覆盖集)

    Asteroids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 24789   Accepted: 13439 Descr ...

  9. Android 停止调试程序

    现在我知道怎么停掉debug的Android程序了,很简单,进入ddms界面,对着你的进程,kill.

  10. Windows Server 笔记(七):Windows Server 2012 R2 NIC Teaming(NIC组)

    什么是NIC Teaming?         NIC Teaming 就是将两个或更多的网络适配器组合在一起,从而达到容错和带宽聚合作用.NIC Teaming 中的每个网络适配器都是物理存在的(虚 ...