D. Moodular Arithmetic Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/problem/D Description As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State Uni…
B - Moodular Arithmetic 题目大意:题意:告诉你p和k,其中(0<=k<=p-1),x属于{0,1,2,3,....,p-1},f函数要满足f(k*x%p)=k*f(x)%p,f(x)的范围必须在[0.p-1]内,问这样的f函数有多少个. 思路:数学题不会写啊啊啊啊.. 一般这种题和费马小定理有关系,寻找循环节. 我们可以发现当k = 0 是答案为 p ^ (p - 1) k = 1 时答案为p ^ p 否则 首先我们知道f(0) = 0; 我们到最小的 r 使得 k ^…
A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/problem/A Description Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maxi…
水 A - Uncowed Forces #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 5; const int INF = 0x3f3f3f3f; int main(void) { int s[5] = {50, 100, 150, 200, 250}; int m[5], w[5], hs, hu; for (int i=0; i<5; ++i) { sc…
C. Alternative Thinking Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/problem/C Description Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary…
B. More Cowbell Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/problem/B Description Kevin Sun wants to move his precious collection of n cowbells from Naperthrill to Exeter, where there is actually grass instead of co…
http://codeforces.com/contest/978/problem/D 题目大意: 给你一个长度为n的b(i)数组,你有如下操作: 对数组中的某个元素+1,+0,-1.并且这个元素只能修改一次 问:是否有操作能吧这个数组变成等差 如果有,请输出把他变成等差的最小步数.否则输出-1: 思路: 定等差的值即可 暴力b1和b2的+1,+0,-1,即可得到等差的值…
题意与分析 (CodeForces - 603A) 这题真的做的我头疼的不得了,各种构造样例去分析性质... 题意是这样的:给出01字符串.可以在这个字符串中选择一个起点和一个终点使得这个连续区间内所有的位取反.求经过处理后最多会得到多少次01变换(可以不连续). 首先求原串的最长01长度,这个太简单了,然后才是重头戏:精彩的构造样例分类讨论环节--如何增加01的最长串? 我们考虑一下反转串的几种情况:1.反转单个连续0/1串的内部:2.反转两个部分连续0/1串与中间的内容(内部无连续串)3.反…
题意与分析(CodeForces 604B) 题意是这样的:\(n\)个数字,\(k\)个盒子,把\(n\)个数放入\(k\)个盒子中,每个盒子最多只能放两个数字,问盒子容量的最小值是多少(水题) 不要看到这种题目什么都不想,看见最大容量最小值就是起手一个二分,这题运用贪心的思想会更简单. 想一想紫书上有一题是类似的,两个人坐船过河的,也是同样的思路. 我们一定要注意到这样一个结论:如果第一个数没法和某一个数放在一起,那么大于等于它的数一定都只能一个单独的盒子了.设这个数是第\(p\)个,那么就…
Lieges of Legendre 题意:有n堆牛,每堆有ai头牛.两个人玩一个游戏,游戏规则为: <1>从任意一个非空的堆中移走一头牛: <2>将偶数堆2*x变成k堆,每堆x头牛(可以增加牛的个数) 移走最后一头牛的人获胜: 数据:n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ 109).a1, a2, ... an (1 ≤ ai ≤ 109) 分析:这显然是SG函数与SG定理的应用: SG函数与SG定理:SG[x] = mex(S);其中S是所有x的后继…