| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:暴力能过,时间只要0ms,内存为284KIn Reply To:暴力能过,时间只要0ms,内存为284K Posted by:luchenqun at 2010-07-29 16:39:36 > #include<iostream>
> using namespace std;
> int array[10008]={0};
> int f(int n)
> {
> if(n%2==0)
> return f(n/2)+1;
> if(n%2!=0&&n>1)
> return f(3*n+1)+1;
> if(n==1)
> return 1;
> }
> int main()
> {
> int i,a,b,m,n;
> for(i=1;i<=10000;i++)
> array[i]=f(i);
> while(cin>>m>>n)
> {
> a=m<n?m:n;
> b=m>n?m:n;
> int max=0;
> for(i=a;i<=b;i++)
> if(array[i]>max)
> max=array[i];
> cout<<m<<" "<<n<<" "<<max<<endl;
> }
>
> return 0;
> }
请问为什么 MAX 不可以在定义a,b,i等字符的时候一起定义阿
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator