CF# 334 Moodular Arithmetic】的更多相关文章

B. Moodular Arithmetic time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia S…
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 ^…
思路: 易知k = 0的时候答案是pp-1,k = 1的时候答案是pp. 当k >= 2的时候,f(0) = 0,对于 1 <= n <= p - 1,如果f(n)确定,由题意可知f(kin mod p)也随之确定,那么这种迭代什么时候停止呢?这就需要找出循环节,即能使km mod p = 1的最小的m,这个m就是k的阶数o(k).这里(G = Np - {0}, 模p乘法)实际上是一个循环群,设G中的元素k的阶数o(k) = m, 则k作为生成元生成的子群也是循环群,并且子群的阶为m且…
E. Arithmetic Progression 链接 题意: 交互题. 有一个等差序列,现已打乱顺序,最多询问60次来确定首项和公差.每次可以询问是否有严格大于x的数,和查看一个位置的数. 分析: 首先可以二分找到序列的最大值,然后考虑如何求公差. 随机选30个数,然后对任意两个求一遍gcd即可. 正确性证明 代码: #include<cstdio> #include<algorithm> #include<cstring> #include<iostream…
C. Lieges of Legendre time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kevin and Nicky Sun have invented a new game called Lieges of Legendre. In this game, two players take turns modifying…
A. Alternative Thinking time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of…
题意:给出方程 f(kx%p)=kf(x)%p ,f:A->B,不同的映射函数f有几种,其中f,A,B值域为{0,1,2..p-1},p为素数(除了2),k为小于p的一个常数. 思路:明显是求循环节的. 首先分析特殊情况: k==0:f(x)=0.其余f(x)为值域中任何一个值,所以有p^(p-1)种: k==1:f(x)=x.所以有p^(p)种: 其他: 若已知f(x)=n,则f(kx),f(k^2*x),f(k^3*x),...f(k^m*x)的值都求的出来:f(k^2*x%p)=k^2*f…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State University (BGU) under…
A.Alternative Thinking(思维) 给出一个01串,你可以取反其中一个连续子串,问取反后的01子串的最长非连续010101串的长度是多少. 我们随便翻一个连续子串,显然翻完之后,对于这个连续子串而言,最后的答案一定不会变优.只会对你翻的左端点和右端点相邻的数字产生贡献.我们计左端点为l,右端点为r.而且要想最大化贡献,必须要使得这个a[l]和a[l-1]一样.a[r]和a[r+1]一样.那么我们只要找到可以使这个贡献获得最大时的条件就行了. # include <cstdio>…