URAL1079
2013-11-30 22:23
253 查看
Problem E
Time Limit : 4000/2000ms (Java/Other) Memory Limit : 32768/16384K (Java/Other)
Total Submission(s) : 15 Accepted Submission(s) : 7
[align=left]Problem Description[/align]
Consider the sequence of numbers ai, i = 0, 1, 2, …, which satisfies the following requirements:
a0 = 0
a1 = 1
a2i = ai
a2i+1 = ai + ai+1
for every i = 1, 2, 3, … .
Write a program which for a given value of n finds the largest number among the numbers a0, a1, …, an.
[align=left]Input[/align]
You are given several test cases (not more than 10). Each test case is a line containing an integer n (1 ≤ n ≤ 99 999). The last line of input contains 0.
[align=left]Output[/align]
For every n in the input write the corresponding maximum value found.
[align=left]Sample Input[/align]
Time Limit : 4000/2000ms (Java/Other) Memory Limit : 32768/16384K (Java/Other)
Total Submission(s) : 15 Accepted Submission(s) : 7
[align=left]Problem Description[/align]
Consider the sequence of numbers ai, i = 0, 1, 2, …, which satisfies the following requirements:
a0 = 0
a1 = 1
a2i = ai
a2i+1 = ai + ai+1
for every i = 1, 2, 3, … .
Write a program which for a given value of n finds the largest number among the numbers a0, a1, …, an.
[align=left]Input[/align]
You are given several test cases (not more than 10). Each test case is a line containing an integer n (1 ≤ n ≤ 99 999). The last line of input contains 0.
[align=left]Output[/align]
For every n in the input write the corresponding maximum value found.
[align=left]Sample Input[/align]
input | output |
---|---|
5 10 0 | 3 4 |
#include<stdio.h> int main() { int i,j,n,max; int a[200005]; while(~scanf("%d",&n)&&n!=0) { max=0; a[0]=0; a[1]=1; for(i=1;i<=n;i++) { a[2*i]=a[i]; a[2*i+1]=a[i]+a[i+1]; } for(i=0;i<=n;i++) if(a[i]>=max) max=a[i]; printf("%d\n",max); } return 0; }
相关文章推荐
- Ural1079-Maximum
- URAL 1079 Maximum 递推
- 51nod 1062 && URAL 1079 Maximum RMQ
- Ural 1079 - Maximum
- URAL1079:Maximum
- ural1221. Malevich Strikes Back!
- ural 1297 Palindrome(后缀数组)
- URAL 1183 Brackets Sequence 记忆化搜索 + DFS
- Ural 1287. Mars Canals
- [Ural1022]Genealogical Tree
- 【转】ural 1745
- Ural 1260 Nudnik Photographer
- Ural 1119 Metro
- URAL 1012 K-based Numbers. Version 2(DP+高精度)
- ural1057 Amount of Degrees
- URAL 1774 Barber of the Army of Mages 最大流
- URAL 1081. Binary Lexicographic Sequence(简单dp)
- Ural 1519. Formula 1 优美的插头DP
- poj 1079 Calendar Game(博弈论 SG)
- 后缀数组poj2774(hdu1403)ural1517