HDU 2802 F(N) 数论+打表】的更多相关文章

题目大意:f[n]-n^3=f[n-2]-(n-1)^3 (n >=3),f[1]=1,f[2]=7,求f[n]. 题目思路:将n^3移到到等式右边化简的到:f[n]=f[n-2]+3n*(n-1)+1: 因为第n项与第n-2项有关,所以知道了f[1]与f[2]的值可以分奇偶打下表,找到循环节为4018. #include<cstdio> #include<stdio.h> #include<cstdlib> #include<cmath> #incl…
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…
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…
题目链接 F(N) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4579 Accepted Submission(s): 1610 Problem Description Giving the N, can you tell me the answer of F(N)? Input Each test case contains a si…
题目链接:HDU 2009-4 Programming Contest 分析:具有一定的周期性——4018处理下就可以A了 Sample Input Sample Output AC代码: #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<iostream> #include<queue> #include<map>…
寻找素数对 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8771    Accepted Submission(s): 4395 Problem Description 哥德巴赫猜想大家都知道一点吧.我们如今不是想证明这个结论,而是想在程序语言内部可以表示的数集中,随意取出一个偶数,来寻找两个素数,使得其和等于该偶数. 做好了这件实…
HDU 1005 Number Sequence(数论) Problem Description: A number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. Given A, B, and n, you are to calculate the value of f(n).   Input The input consists of multipl…
原题直通车:HDU 4734 F(x) 题意:F(x) = An * 2n-1 + An-1 * 2n-2 + ... + A2 * 2 + A1 * 1, 求0.....B中F[x]<=F[A]的个数. 代码: // 31MS 548K 931 B G++ #include<iostream> #include<cstdio> #include<cstring> using namespace std; int digit[11], dp[11][6000],…
HDU  4548  美素数(打表)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88159#problem/H 题目: Description 小明对数的研究比较热爱,一谈到数,脑子里就涌现出好多数的问题,今天,小明想考考你对素数的认识.         问题是这样的:一个十进制数,如果是素数,而且它的各位数字和也是素数,则称之为“美素数”,如29,本身是素数,而且2+9 = 11也是素数,所以它是美素数.   …
UVA305 - Joseph(数论 + 打表) 题目链接 题目大意:约瑟夫环问题:n个人围成一圈,每次都淘汰第m个人,问最后一个幸存下来的人的编号. 这题的意思有点不一样,它规定前面的k个人是好人,后面的k个人是坏人(2 ∗ k形成环).问最小的m是多少,可以先把后面的k个坏人淘汰再淘汰好人. 解题思路:这题有个递推式:ai = (ai - 1 + m - 1) % (2 ∗ k - (i - 1)) ai表示第i次淘汰的人的编号.后面取余的是剩下的人数. 注意这题的k仅仅可能有14种,可是測…