codeforces 155D 质数】的更多相关文章

题意:有编号1到n的n台机器,有m次操作,操作为开启或关闭机器,成功开启机器k的条件为k和所有已经开启的机器编号互质. 思路:vis[i]数组存放占领i这个位置的机器编号,因为所有开启的机器的编号互质,所以每个i至多只被1台机器占领.open数组保存机器的开启状态. 开启编号为k的机器操作:枚举k的所有因子,若vis[k的任意因子]=0,则成功开启,vis[k的任意因子]=k,open[k]=1. 关闭编号为k的机器操作:枚举k的所有因子,vis[k的任意因子]=0. #include<cstd…
链接: https://codeforces.com/contest/1228/problem/C 题意: Let's introduce some definitions that will be needed later. Let prime(x) be the set of prime divisors of x. For example, prime(140)={2,5,7}, prime(169)={13}. Let g(x,p) be the maximum possible int…
A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #define TS printf("!!!\n") #define pb push_back #define inf 1e9 //std::ios::sync_with_stdio(false); using namespace std; //priority_queue<int,vect…
A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #define TS printf("!!!\n") #define pb push_back #define inf 1e9 //std::ios::sync_with_stdio(false); using namespace std; //priority_queue<int,vect…
题面 链接:CF548E Description Mike is a bartender at Rico's bar. At Rico's, they put beer glasses in a special shelf. There are n kinds of beer at Rico's numbered from 1 to n. i-th kind of beer has *a**i* milliliters of foam on it. Maxim is Mike's boss. T…
C. Tennis Championship(递推,斐波那契) 题意:n个人比赛,淘汰制,要求进行比赛双方的胜场数之差小于等于1.问冠军最多能打多少场比赛.题解:因为n太大,感觉是个构造.写写小数据,看看有没有结论. 2 3 4 5 6 7 8 9 10 11 12 (人数) 1 2 2 3 3 3 4 4 4 4 4 (比赛数) 发现比赛数的增长成斐波那契.维护一个前缀和即可. #include <bits/stdc++.h> #define ll long long using names…
Codeforces A                     B                        C                             D                                   E                                  57 div2         比较简单的题!树状数组维护!             75 div1   简单题!排序~                               …
A - Noldbach problem 题面链接 http://codeforces.com/contest/17/problem/A 题面 Nick is interested in prime numbers. Once he read about Goldbach problem. It states that every even integer greater than 2 can be expressed as the sum of two primes. That got Nic…
A - A Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 300C Description Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the deci…
题目链接:http://codeforces.com/contest/327/problem/C 首先先算出一个周期里面的值,保存在ans里面,就是平常的快速幂模m做法. 然后要计算一个公式,比如有k个部分,那么对于没一个位置i, 都有2^i + 2^(i+n) + ... + 2^(i+(k-1)*n) = 2^i(1 + 2^n + ... + 2^((k-1)*n)) = 2^i * (1-2^(n*k))/(1-2^n) 所以结果就是ans * (1-2^(n*k))/(1-2^n) %…