HDU 2802 F(N)(简单题,找循环解)】的更多相关文章

题目链接 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…
超级无敌简单题 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 570    Accepted Submission(s): 274 Problem Description 通常来说,题面短的题目一般都比较难,所以我要把题面写得很长很长.通常来说,题面短的题目一般都比较难,所以我要把题面写得很长很长.通常来说,题面短的题目一般都比较难,所…
题目链接: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>…
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]-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…
今早水出的第一道题,带着情绪做的,竟然1Y了,确实惊奇.这道简单的线性递推取模,直接递推是不行的,因为n的规模达到了100,000,000,要么超时要么超内存.可以用矩阵快速幂来搞,根据题意构建出对应的矩阵后即可(第一次写的,用结构体来进行矩阵相乘运算),代码如下: #include<cstdio> struct matrix{ int a,b,c,d; matrix(, , , ) { a=_a; b=_b; c=_c; d=_d; } matrix operator *(const mat…
Problem Description The school set up three elective courses, assuming that these courses are A, B, C. N classes of students enrolled in these courses.Now the school wants to count the number of students who enrolled in at least one course in each cl…
简单题,但要考虑一些细节: 前导0不要,后导0不要,小数长度不一样时,有进位时,逆置处理输出 然后处理起来就比较麻烦了. 题目链接 我的代码纯模拟,把小数点前后分开来处理,写的很繁杂,纯当纪念——可怜我的眼睛. #include<string.h> #include<stdio.h> int i,la,lb,la1,lb1,la2,lb2,lc1,lc2,yi,temp; ],b[],a1[],a2[],b1[],b2[],c1[],c2[]; void nizhi1(){ ; c…
题目: 平方和与立方和 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 108212    Accepted Submission(s): 34915 Problem Description 给定一段连续的整数.求出他们中全部偶数的平方和以及全部奇数的立方和.   Input 输入数据包括多组測试实例,每组測试实例包括一行,由两个整数m和…
找循环节水题.注意余数大于0. /* 2802 */ #include <cstdio> #include <cstring> #include <cstdlib> #define MAXN 4018 #define MOD 2009 __int64 a[MAXN+]; void init() { __int64 tmp; int i, j, k; bool flag; a[]=, a[] = , a[] = ; ; i<=MAXN; ++i) { tmp = i…