传送门:http://codeforces.com/contest/755 A题题意是给你一个数字n,让你找到一个数字m,使得n*m+1为合数,范围比较小,直接线性筛出1e6的质数,然后暴力枚举一下就好了. #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <vector> #i…
题目链接:http://codeforces.com/contest/755 本蒟蒻做了半天只会做前两道题.. A. PolandBall and Hypothesis 题意:给出n,让你找出一个m,使n*m+1不是素数. 数据很小,直接暴力枚举. #include<cstdio> #include<iostream> #include<cmath> using namespace std ; bool prime( int n ) { for( int i = 2 ;…
题目链接:http://codeforces.com/contest/755/problem/C 题意:PolandBall 生活在一个森林模型的环境中,定义森林由若干树组成,定义树为K个点,K-1条无向边的图.现在给定每个家庭在对应的树上离他最远的另一个家庭的编号.问这个森林有多少棵树组成. 思路:由于只给出了每个点在树上离他最远的点的坐标而不知道整体结构,但是可以知道该点和给定离他最远的点一定是在同一颗树上,所以维护一个并查集,最后有多少个连通分量就是有多少棵树了. import java.…
题目链接:http://codeforces.com/contest/755/problem/B 题意:给定PolandBall 和EnemyBall 这2个人要说的单词,然后每一回合轮到的人要说一个单词,之前说过的单词不能再说,当轮到某个人的回合没单词说即输.每人都采取最优策略,PolandBall 先说问PolandBall 是否能赢. 思路: 首先两个的单词可以分为相同和不相同两个部分,由于说过的词不能重复说所以比起说不相同的那部分的单词还是说相同的那部分比较优,因为说了一个对面有的但是目…
题目链接:http://codeforces.com/contest/755/problem/A 题意:给定一个正整数N,问你是否存在一个数M使得N*M+1不是素数(M的范围在[1,1000]). 思路:考虑到M的范围很小,直接暴力搞. import java.io.PrintWriter; import java.util.*; public class Main { public static final int MAXN=100000+10; public static boolean i…
A. Petr and a calendar time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to wee…
D. Jerry's Protest 题目连接: http://www.codeforces.com/contest/626/problem/D Description Andrew and Jerry are playing a game with Harry as the scorekeeper. The game consists of three rounds. In each round, Andrew and Jerry draw randomly without replaceme…
在家补补题   模拟 A - Robot Sequence #include <bits/stdc++.h> char str[202]; void move(int &x, int &y, char ch) { if (ch == 'U') x--; if (ch == 'D') x++; if (ch == 'L') y--; if (ch == 'R') y++; } int main(void) { int n; scanf ("%d", &…
题目链接:http://codeforces.com/contest/626/problem/C 题意就是给你n个分别拿着2的倍数积木的小朋友和m个分别拿着3的倍数积木的小朋友,每个小朋友拿着积木的数量互不相同,求小朋友中拿着最大积木数的最小的情况(有点绕). 那最坏的情况就是2n或者3m,假设最大的积木数为x,x肯定能被2或3整除,那么x/2就是2的倍数个数,x/3就是3的倍数的个数,x/6就是6的倍数的个数. 因为这个数据量很小,那么只要暴力寻找刚好符合x/3 + x/2 - x/6 >=…
C. Lieges of Legendre 题意:给n,m表示有n个为2的倍数,m个为3的倍数:问这n+m个数不重复时的最大值 最小为多少? 数据:(0 ≤ n, m ≤ 1 000 000, n + m > 0) ps:很水的题,主要是策略: 思路:由于里面每隔6就会重复一次,不好直接模拟,并且模拟的效率很低,那就二分吧!二分即上界为2单独的最大倍数与3单独时的最大倍数之和,下界为前面二者的max;之后利用判断是否mid/2 >= n && mid/3 >= m &am…