codeforce 603B - Moodular Arithmetic】的更多相关文章

题意:给出方程 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…
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且…
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>…
水 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…
An arithmetic progression is such a non-empty sequence of numbers where the difference between any two successive numbers is constant. This constant number is called common difference. For example, the sequence 3, 7, 11, 15 is an arithmetic progressi…
A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same. For example, these are arithmetic sequences: 1, 3, 5, 7, 9 7, 7, 7, 7 3, -1, -5, -9 The follo…