HDU - 2802 F(N) (周期)】的更多相关文章

题目链接: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>…
题目链接 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…
题目大意: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…
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…
原题直通车: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],…
题意: 已知f[1] = f[2] = 1,输入三个数a,b,n,求f[n] = (a*f[n-1]+b*f[n-2])%7的结果 分析: f[n-1]和f[n-2]最多为7种情况(0,1,2,3,4,5,6),则它们的组合最多为49,即周期为49. 代码如下: #include <iostream> #include <cstdio> #include <cstring> #include <fstream> #include <ctime>…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4734 数位DP. 用dp[i][j][k] 表示第i位用j时f(x)=k的时候的个数,然后需要预处理下小于k的和,然后就很容易想了 dp[i+1][j][k+(1<<i)]=dp[i][j1][k];(0<=j1<=j1) AC代码: #include <iostream> #include <cstdio> #include <cstring> #i…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4734 Time Limit: 1000/500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description For a decimal number x with n digits (AnAn-1An-2 ... A2A1), we define its weight as F(x) = An * 2n…
F - Finding Seats Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1937 Description A group of K friends is going to see a movie. However, they are too late to get good tickets, so they are looki…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4734 题意:我们定义十进制数x的权值为f(x) = a(n)*2^(n-1)+a(n-1)*2(n-2)+...a(2)*2+a(1)*1,a(i)表示十进制数x中第i位的数字. 题目给出a,b,求出0~b有多少个不大于f(a)的数 显然这题可以设这样的dp dp[len][count]表示前len位权值为count的有多少,然后显然的在len==0时return count>=f(a); 但是这样…