// 因为是中文题面就偷一次懒不写题意啦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. ES6-总结

    在最近进行的项目中,已经全面使用到ES6,这里对ES6进行整理总结.用得比较多的是带*的内容,这些语法.新增类型.模块调用等从代码量上.可读性上.操作上给项目带来了不少便利.   1.语法 1.1.命 ...

  2. PhotoSwipe图片展示插件

    这个插件相当棒!功能也很强大,可以自行体会. 官方网址:http://www.photoswipe.com/ github地址:https://github.com/codecomputerlove/ ...

  3. 第1章 VMware中安装CentOS7

    目录 1.1 下载CentOS7安装包 1.2 VMware中新建虚拟机 1.3 安装操作系统 本章讲解在VMware中安装CentOS虚拟机的步骤.使用的VMware Workstation版本为1 ...

  4. GoF23种设计模式之创建型模式之抽象工厂模式

    一.概述 提供一个创建一系列相关或相互依赖对象的接口,而无需指定它们具体的类. 二.适用性 1.一个系统要独立于它的产品的创建.组合和表示的时候. 2.一个系统要由多个产品系列中的一个来配置的时候. ...

  5. 标准C++中string类的用法总结

    相信使用过MFC编程的朋友对CString这个类的印象应该非常深刻吧?的确,MFC中的CString类使用起来真的非常的方便好用.但是如果离开了MFC框架,还有没有这样使用起来非常方便的类呢?答案是肯 ...

  6. Codeforces Round #524 (Div. 2) C. Masha and two friends 思路

    题目:题目链接 思路:直接计数显然是不好处理的,但分情况讨论只要不写错这题是一定可以出的,但这样基本做完这个题就没时间做其他题了,但当时我就这么蠢的这样做了,比赛一个半小时的时候突然发现一个似乎可行的 ...

  7. L1-049 天梯赛座位分配 (20 分)

    天梯赛每年有大量参赛队员,要保证同一所学校的所有队员都不能相邻,分配座位就成为一件比较麻烦的事情.为此我们制定如下策略:假设某赛场有 N 所学校参赛,第 i 所学校有 M[i] 支队伍,每队 10 位 ...

  8. Hive 分析函数lead、lag实例应用

    Hive的分析函数又叫窗口函数,在oracle中就有这样的分析函数,主要用来做数据统计分析的. Lag和Lead分析函数可以在同一次查询中取出同一字段的前N行的数据(Lag)和后N行的数据(Lead) ...

  9. leetcode 【 Minimum Path Sum 】python 实现

    题目: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right w ...

  10. Delphi字符串处理函数

    1.Copy 功能说明:该函数用于从字符串中复制指定范围中的字符.该函数有3个参数.第一个参数是数据源(即被复制的字符串),第二个参数是从字符串某一处开始复制,第三个参数是要复制字符串的长度(即个数) ...