zoukankan      html  css  js  c++  java
  • URAL1079

                                     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
    inputoutput
    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
    ",max);
        }
        return 0;
    }
    
  • 相关阅读:
    求js数组中最小值
    分析apply,call方法
    前端模块化详解
    js中形参的小练习
    js中return返回值小练习
    mysql 视图
    mysql 数据库语句
    mysql 事务管理
    vue-前端工程化
    Vue-router
  • 原文地址:https://www.cnblogs.com/cancangood/p/3451845.html
Copyright © 2011-2022 走看看