// 因为是中文题面就偷一次懒不写题意啦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. 11、python中的函数(基础)

    一.什么是函数? 在数学中,x2+2x2+3=10这样的叫方程. 而ax2+bx2+c=d这样的才叫函数.数学的函数中,abcd等待输入的未知量叫自变量,它需要我们自己去输入,而x这种待求得未知量叫因 ...

  2. mysql练习题练习

    1.数据库是按照原文制作的,表格结构一样具体存储的数据有些差异 原文地址:MySQL练习题 原答案地址:MySQL练习题参考答案 2.查询“生物”课程比“物理”课程成绩高的所有学生的学号: selec ...

  3. 关于tree节点的刷新

    1.刷新节点分为刷新整个树和刷新指定节点 (1)刷新整个树 $("#tree").tree("reload"); (2)刷新指定节点(方法:传入需要刷新节点的父 ...

  4. WTForm

    Flask-WTForm: from flask import Flask,render_template,request,redirect from wtforms.fields import co ...

  5. 关于mongodb的安装运行

    最近在学习node.js,在实例的项目中要用到mongodb做数据库.于是便记录一下mongodb的安装流程和遇到的坑: 1.下载地址:http://www.mongodb.org/downloads ...

  6. 【IPv6】ISATAP隧道技术详解

    一.基本概念       ISATAP(Intra-SiteAutomatic Tunnel Addressing Protocol)    ISATAP是一种非常容易部署和使用的IPv6过渡机制.在 ...

  7. 第一次接触php

    一.什么是PHP PHP的中文意思:超文本预处理器,英文名字: HyperText Preprocessor. PHP通常有两层含义: (1)PHP是一个编程语言. (2)PHP是处理PHP编程语言的 ...

  8. 47.关于gradle的解疑

    Short Answer Gradle is a build system. Long Answer Before Android Studio you were using Eclipse for ...

  9. leetcode 【 Copy List with Random Pointer 】 python 实现

    题目: A linked list is given such that each node contains an additional random pointer which could poi ...

  10. Leetcode 599.两个列表的最小索引总和

    两个列表的最小索引总和 假设Andy和Doris想在晚餐时选择一家餐厅,并且他们都有一个表示最喜爱餐厅的列表,每个餐厅的名字用字符串表示. 你需要帮助他们用最少的索引和找出他们共同喜爱的餐厅. 如果答 ...