Problem E

Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 32768/16384K (Java/Other)
Total Submission(s) : 15   Accepted Submission(s) : 7
Problem Description
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.
 
Input
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.
 
Output
For every n in the input write the corresponding maximum value found.
 
Sample Input
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的更多相关文章

随机推荐

  1. 爆牙齿的 Web 标准面试题 【转藏】

    <!DOCTYPE html> <html lang="zh-CN"><head> <meta http-equiv="cont ...

  2. Android30-Fragment-理解

        Android30-Fragment-理解 规范 mobileSafe V2.0 欢迎页面 用户第一次是否需要用户提示 新闻类app的数据是怎么获取的 知乎提问?如何把身边资源最大化 第二种就 ...

  3. Git查看、删除、重命名远程分支和tag

    这篇文章记录我在使用git的过程中碰到远程分支和tag的相关内容,提纲: 查看远程分支 删除远程分支和tag 删除不存在对应远程分支的本地分支 重命名远程分支 把本地tag推送到远程 获取远程tag ...

  4. CSS Padding(填充)

    CSS Padding(填充)属性定义元素边框与元素内容之间的空间. Padding(填充) 当元素的 Padding(填充)(内边距)被清除时,所"释放"的区域将会受到元素背景颜 ...

  5. ListPreference之entries和entryValues

    在使用PreferenceActivity时,碰到配置文件的ListPreference有两个属性android:entries,android:entryValues.这两个属性其实就和html的o ...

  6. ios专题 - OCUnit

    OCUnit是集成在Xcode开发环境的单元测试框架:OCUnit运行必须包含SenTestingKit.framework这个库: 针对需要测试的类,每个类写出自己的TestCase,独立组织一个文 ...

  7. 读书笔记之深入分析Java Web技术内幕

    章节: 1 B/SB/S的优点: 客户端使用统一的浏览器(Browser) ,浏览器的统一带来了操作的统一,无论使用什么服务,因为浏览器是相同的,所以操作类似.客户使用简单了.服务端开发简化; 使用统 ...

  8. VPN ,Bypass the FIrewall

    Bypass the China Firewall Methods November 16th, 2012Posted in , Tech With their assortment of techn ...

  9. Xcode-程序开发设计-02九宫格

    行号是除 决定Y值 列号是余 决定X值 // // ViewController.m // 06-应用管理 // // Created by daier on 15/12/31. // Copyrig ...

  10. CocoaPods ADD private Spec Repo

    Private Pods CocoaPods is a great tool not only for adding open source code to your project, but als ...