hdu1005 Number Sequence---找循环节】的更多相关文章

题意,f(1)=1,f(2)=1,f(n)=a*f(n-1)+b*f(n-2),求f(n)%7 这个题可能数据不够严谨,所以有些错误的做法也可以通过,比如7 7 50,应该输出0而不是1 解:找到关键字%7,那么能说明每一步都%7,最终答案也就是%7的,如果每一步都%7,那么对于任意f(n)来说,f(n-1)有7种情况,f(n-2)有7种情况,一共最多只有49种情况,说明这里有循环节,而且循环节的长度不超过49.需要注意的是,这里只能证明循环节的长度不超过49,并不能证明f(1)和f(2)就在循…
主题链接: pid=1005">huangjing 题意: 就是给了一个公式,然后求出第n项是多少... 思路: 题目中n的范围实在是太大,所以肯定直接递推肯定会超时,所以想到的是暴力打表,找循环节,可是也不是那么easy发现啊,所以这时候分析一下,由于最后都会mod7,所以总共同拥有7X7总情况,即A 0,1,2,3,4,5,6,7.B也是如此,所以循环节为49,这么这个问题就攻克了. .. 题目: Number Sequence Time Limit: 2000/1000 MS (Ja…
题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=2065 递推类题目, 可以考虑用数学方法来做, 但是明显也可以有递推思维来理解. 递推的话基本就是状态转移了, 如何找状态是递推的关键. 我们把这个分为四个状态 A 出现次数的奇偶和B出现状态的奇偶,我们可以构造出四个状态: A        B 第一个状态 :        偶       偶     0 第二个状态 :        偶       奇     1 第三个状态 :        …
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1005 Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 198316    Accepted Submission(s): 49744 Problem Description A number sequence…
找到循环节,然后对应的变换 Cipher Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 20377   Accepted: 5491 Description Bob and Alice started to use a brand-new encoding scheme. Surprisingly it is not a Public Key Cryptosystem, but their encoding and de…
题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12869 解题报告:看到n的范围这么大,一看就是找规律,把前30个打出来之后就找到了循环节,循环节从第25个开始,长度为6.离线打表,把所有结果都打出来了. #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using name…
Problem B Number Sequence Input: standard input Output: standard output Time Limit: 1 second A single positive integer i is given. Write a program to find the digit located in the position i in the sequence of number groups S1S2…Sk. Each group Sk con…
Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 149022    Accepted Submission(s): 36261 Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A…
Number Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 86102 Accepted Submission(s): 20423 Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n…
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). InputThe input consists of multiple test cases. Each test case contains 3 integers A,…