由0和1组成的串中,不能表示为由几个相同的较小的串连接成的串,称为本原串,有多少个长为n(n<=100000000)的本原串? 答案mod2008. 例如,100100不是本原串,因为他是由两个100组成,而1101是本原串. Input 输入包括多个数据,每个数据一行,包括一个整数n,代表串的长度. Output 对于每个测试数据,输出一行,代表有多少个符合要求本原串,答案mod2008. Sample Input 1 2 3 4 Sample Output 2 2 6 12 解析: 考虑所有…
http://acm.hdu.edu.cn/showproblem.php?pid=2197 长度为n的01串有2的n次方个,再减去不符合要求的.不符合要求的字符串就是长度为n的约数的字符串. 递归处理,然后用map映射记录求出的每一个数的值,为以后再次输入处理过的数,就可以直接输出,不用递归处理. #include <cstdio> #include <cstring> #include <map> #define ll long long #include <…
In number theory, Euler's totient function φ(n) counts the positive integers up to a given integer n that are relatively prime to n. It can be defined more formally as the number of integers k in the range 1≤k≤n for which the greatest common divisor…
HazelFan is given two positive integers a,b, and he wants to calculate amodb. But now he forgets the value of b and only remember the value of a, please tell him the number of different possible results. Input The first line contains a positive integ…
This time I need you to calculate the f(n) . (3<=n<=1000000) f(n)= Gcd(3)+Gcd(4)+-+Gcd(i)+-+Gcd(n). Gcd(n)=gcd(C[n][1],C[n][2],--,C[n][n-1]) C[n][k] means the number of way to choose k things from n some things. gcd(a,b) means the greatest common di…
Problem Description Now given two kinds of coins A and B,which satisfy that GCD(A,B)=1.Here you can assume that there are enough coins for both kinds.Please calculate the maximal value that you cannot pay and the total number that you cannot pay. Inp…
Your job is simple, for each task, you should output Fn module 109+7. Input The first line has only one integer T, indicates the number of tasks. Then, for the next T lines, each line consists of 6 integers, A , B, C, D, P, n. 1≤T≤200≤A,B,C,D≤1091≤P,…
There are an equation. ∑0≤k1,k2,⋯km≤n∏1⩽j<m(kj+1kj)%1000000007=? We define that (kj+1kj)=kj+1!kj!(kj+1−kj)! . And (kj+1kj)=0 while kj+1<kj. You have to get the answer for each n and m that given to you. For example,if n=1,m=3, When k1=0,k2=0,k3=0,(k…
如果一个串能完全由其子串组成,那么这个串就不是本源串 求长度为n的本源串的个数. 由定义一个串如果不是本源串,那么他的长度一定是组成其子本源串的长度的(>=1) 整数倍. 那么长度为n的串总个数是2^n个 枚举n 的因子 长度为n的 本源串的个数就是2^n - a[k1]-a[k2]-..(k1 k2..是n的非n因子). 因为n可以非常的大,所以需要快速幂,不能直接打表,求因子的复杂度是根号n 所以在线算,查,记忆化一下还是很快的. #include <stdio.h> #includ…
RXD is a good mathematician. One day he wants to calculate: output the answer module 109+7. p1,p2,p3-pk are different prime numbers Input There are several test cases, please keep reading until EOF. There are exact 10000 cases. For each test case, th…
Ignatius's puzzle Problem Description Ignatius is poor at math,he falls across a puzzle problem,so he has no choice but to appeal to Eddy. this problem describes that:f(x)=5x13+13*x5+ka*x,input a nonegative integer k(k<10000),to find the minimal none…
Describtion First we define: (1) lcm(a,b), the least common multiple of two integers a and b, is the smallest positive integer that is divisible by both a and b. for example, lcm(2,3)=6 and lcm(4,6)=12. (2) gcd(a,b), the greatest common divisor of tw…
Giving the N, can you tell me the answer of F(N)? Input Each test case contains a single integer N(1<=N<=10^9). The input is terminated by a set starting with N = 0. This set should not be processed. Output For each test case, output on a line the v…
Problem Description 七夕节那天,月老来到数字王国,他在城门上贴了一张告示,并且和数字王国的人们说:"你们想知道你们的另一半是谁吗?那就按照告示上的方法去找吧!" 人们纷纷来到告示前,都想知道谁才是自己的另一半.告示如下: 数字N的因子就是所有比N小又能被N整除的所有正整数,如12的因子有1,2,3,4,6. 你想知道你的另一半吗? Input 输入数据的第一行是一个数字T(1<=T<=500000),它表明测试数据的组数.然后是T组测试数据,每组测试数据…
I will show you the most popular board game in the Shanghai Ingress Resistance Team. It all started several months ago. We found out the home address of the enlightened agent Icount2three and decided to draw him out. Millions of missiles were detonat…
Problem Description When Teddy was a child , he was always thinking about some simple math problems ,such as "What it's 1 cup of water plus 1 pile of dough .." , "100 yuan buy 100 pig" .etc.. One day Teddy met a old man in his dream ,…
A cubic number is the result of using a whole number in a multiplication three times. For example, 3×3×3=27 so 27 is a cubic number. The first few cubic numbers are 1,8,27,64 and 125. Given an prime number p. Check that if p is a difference of two cu…
Description 给nn个小于pp的非负整数a1,-,na1,-,n,问有多少对(i,j)(1≤i<j≤n)(i,j)(1≤i<j≤n)模pp在意义下满足1ai+aj≡1ai+1aj1ai+aj≡1ai+1aj,即这两个数的和的逆元等于这两个数的逆元的和,注意0没有逆元 Input 第一行一整数TT表示用例组数,每组用例首先输入一整数nn表示序列长度和一素数pp表示模数,之后输入nn个非负整数a1,-,n(1≤T≤5,1≤n≤2×105,2≤p≤1018,0≤a1,-,n<p)a1…
Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first mathematicians to study equations where variables were restricted to integral values. In honor of him, these equations are commonly called diophantine e…
先放知识点: 莫比乌斯反演 卢卡斯定理求组合数 乘法逆元 快速幂取模 GCD of Sequence Alice is playing a game with Bob. Alice shows N integers a 1, a 2, -, a N, and M, K. She says each integers 1 ≤ a i ≤ M. And now Alice wants to ask for each d = 1 to M, how many different sequences b…
Describtion In mathematics, the greatest common divisor (gcd) of two or more integers, when at least one of them is not zero, is the largest positive integer that divides the numbers without a remainder. For example, the GCD of 8 and 12 is 4.-Wikiped…
Revenge of GCD Problem Description In mathematics, the greatest common divisor (gcd), also known as the greatest common factor (gcf), highest common factor (hcf), or greatest common measure (gcm), of two or more integers (when at least one of them is…
WhereIsHeroFrom: Zty, what are you doing ? Zty: I want to calculate N!.. WhereIsHeroFrom: So easy! How big N is ? Zty: 1 <=N <=1000000000000000000000000000000000000000000000- WhereIsHeroFrom: Oh! You must be crazy! Are you Fa Shao? Zty: No. I haven'…
The Children's Day has passed for some days .Has you remembered something happened at your childhood? I remembered I often played a game called hide handkerchief with my friends. Now I introduce the game to you. Suppose there are N people played the…
A Central Meridian (ACM) Number N is a positive integer satisfies that given two positive integers A and B, and among A, B and N, we have N | ((A^2)*B+1) Then N | (A^2+B) Now, here is a number x, you need to tell me if it is ACM number or not. Input…
A New Change Problem Problem Description Now given two kinds of coins A and B,which satisfy that GCD(A,B)=1.Here you can assume that there are enough coins for both kinds.Please calculate the maximal value that you cannot pay and the total number tha…
Consider a positive integer X,and let S be the sum of all positive integer divisors of 2004^X. Your job is to determine S modulo 29 (the rest of the division of S by 29). Take X = 1 for an example. The positive integer divisors of 2004^1 are 1, 2, 3,…
七夕节 Problem Description 七夕节那天,月老来到数字王国,他在城门上贴了一张告示,并且和数字王国的人们说:"你们想知道你们的另一半是谁吗?那就按照告示上的方法去找吧!" 人们纷纷来到告示前,都想知道谁才是自己的另一半.告示如下: 数字N的因子就是所有比N小又能被N整除的所有正整数,如12的因子有1,2,3,4,6. 你想知道你的另一半吗? Input 输入数据的第一行是一个数字T(1<=T<=500000),它表明测试数据的组数.然后是T组测试数据,每组…
Everybody knows any number can be combined by the prime number. Now, your task is telling me what position of the largest prime factor. The position of prime 2 is 1, prime 3 is 2, and prime 5 is 3, etc. Specially, LPF(1) = 0. Input Each line will con…
本原串 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1091    Accepted Submission(s): 350 Problem Description 由0和1组成的串中,不能表示为由几个相同的较小的串连接成的串,称为本原串,有多少个长为n(n<=100000000)的本原串?答案mod2008.例如,100100不是本原…