标签:span space cin main ble div gray enter class
第1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 10)
第2 - T + 1行:T个数,表示需要计算的n。(1 <= n <= 10^5)
共T行,每行1个最大值。
2
5
10
3
4
1 #include <bits/stdc++.h> 2 #define N 100005 3 #define ll long long int 4 using namespace std; 5 ll k[N],Max[N]; 6 ll List(int x){ 7 if(x==0||x==1) 8 return x; 9 else if(x%2==0){ 10 return k[x/2]; 11 }else{ 12 return k[x/2]+k[x/2+1]; 13 } 14 } 15 int main(){ 16 int n; 17 cin>>n; 18 ll p=0; 19 for(int i=0;i<=N;i++){ 20 k[i]=List(i); 21 Max[i]=max(p,k[i]); 22 p=Max[i]; 23 } 24 while(n--){ 25 int x; 26 cin>>x; 27 cout<<Max[x]<<endl; 28 } 29 return 0; 30 }
标签:span space cin main ble div gray enter class
原文地址:http://www.cnblogs.com/zllwxm123/p/7511893.html