解题报告:hdu 1005 number subsequent】的更多相关文章

2017-09-06 20:35:59 writer:pprp 本来以为这是一道水题,写了一个递归就赶紧交上去了, 结果超时了,看看数据范围100000000,肯定把栈给爆了 想用记忆化的方法,但是虽然快一点,但是开不到那么大的数组 然后去看了看讨论版,大佬找到一个循环节 这样的题,mod了一个7,结果会出现循环,循环节为 7 * 7 = 49 因为结果一定是0到6之间的数,所以一定会循环,而且循环节不会超过49.(因为前面2个数若相同,则第三个之后的数必相同,而在49内必能找到2个相邻的数在前…
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 1005 Number Sequence(数列) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) [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, an…
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 multiple test…
Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 175657    Accepted Submission(s): 43409 Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1005 题意: 数列{f(n)}: f(1) = 1, f(2) = 1, f(n) = ( A*f(n-1) + B*f(n-2) ) MOD 7 给定A.B.n,求f(n). (1<=n<=100,000,000) 题解: 大水题~ (*/ω\*) 矩阵快速幂. 初始矩阵start: 特殊矩阵special: 所求矩阵ans: ans = start * special^(n-1) ans的第一…
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1126 http://acm.hdu.edu.cn/showproblem.php?pid=1005 注意上面一题和下面一题的区别,上面A,B可能取负数,但是mod跟c++中%是不一样的,mod只会得到非负数,两次跳进这个坑了. 然后就找周期,只要f[i-1]==1&&f[i]==1就可以跳出,然后i-2就是周期,输出n%(i-2)的时候,要注意如果等于0的话,其实…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1005 代码: #include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; ; struct matrix { ][]; }; matrix mul(matrix a,matrix b) { int i,j,k; matrix c; m…
Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 154923    Accepted Submission(s): 37854 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): 89984    Accepted Submission(s): 21437 Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A…
题目链接 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 multiple test cases. Each test ca…
Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 187893    Accepted Submission(s): 46820 Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 177761    Accepted Submission(s): 44124 Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B…
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,…
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 multiple test cases. Each test case…
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 multiple test cases. Each test case contains 3 integers…
#include <stdio.h> #include <string.h> int main() { int a,b,n; int i; ]={}; f[]=; f[]=; while(scanf("%d %d %d",&a,&b,&n)!=EOF){ ){ break; } ;i<;i++){ f[i]=(a*f[i-]+b*f[i-])%; } ){ printf(]); } else{ printf()%+]); } } ;…
题目 第一次做是看了大牛的找规律结果,如下: //显然我看了答案,循环节点是48,但是为什么是48,据说是高手打表出来的 #include<stdio.h> int main() { ],a,b,i,n; f[]=;f[]=; while(scanf("%d%d%d",&a,&b,&n)!=EOF) { &&b==&&n==)break; ;i<;i++) { f[i]=(a*f[i-])%+(b*f[i-])%…
链接:传送门 题意:略 思路:f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7 -> f(n) = (A * f(n-1)%7 + B * f(n-1)%7)%7 检查输出可以发现规律,每48个数一循环,因此只需要打出前50个数的fib表然后对n%7即可. /************************************************************************* > File Name: 1.cpp > Aut…
题意,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)就在循…
题目链接: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): 85249    Accepted Submission(s): 20209 Problem Description A number sequence…
HDU 4303 Hourai Jeweled 解题报告 评测地址: http://acm.hdu.edu.cn/showproblem.php?pid=4303 评测地址: https://xoj.red/contests/view/1155/1 题目描述 Kaguya Houraisan was once a princess of the Lunarians, a race of people living on the Moon. She was exiled to Earth over…
[LeetCode]306. Additive Number 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.me/ 题目地址:https://leetcode.com/problems/additive-number/description/ 题目描述: Additive number is a string whose digits can form additive se…
[解题报告] Leapin' Lizards HDU 2732 网络流 题外话 在正式讲这个题目之前我想先说几件事 1. 如果大家要做网络流的题目,我在网上看到一个家伙,他那里列出了一堆网络流的题目,而且还给他们分门别类,并且标注了难度,感觉挺好的,网址是[夏天的风](https://blog.csdn.net/shahdza/article/details/7779537) 2. 这道题有个坑点!!!! 正题 首先,当然是直接贴上[题目](http://acm.hdu.edu.cn/showp…
[九度OJ]题目1040:Prime Number 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1040 题目描述: Output the k-th prime number. 输入: k≤10000 输出: The k-th prime number. 样例输入: 3 7 样例输出: 5 17 Ways 首先用C++做了一遍,刚开始没有AC的原因是判断素数的函数写的不对,没有处理2这个情况.后来发现每次停止循环的时候…
[LeetCode]Largest Number 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/largest-number/#/description 题目描述: Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], t…
[LeetCode]375. Guess Number Higher or Lower II 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/guess-number-higher-or-lower-ii/description/ 题目描述: We are playing the Guess Game. The game is as f…
[LeetCode]792. Number of Matching Subsequences 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/number-of-matching-subsequences/description/ 题目描述: Given string S and a dictionary of words words,…
[LeetCode]137. Single Number II 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/single-number-ii/description/ 题目描述: Given an array of integers, every element appears three times except for one, which appears exactly once. Find that singl…
[LeetCode]452. Minimum Number of Arrows to Burst Balloons 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/description/ 题目描述: There are a number of spherical balloons spread in two-dimensio…