| ||||||||||
| 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 | |||||||||
谁帮我看看啊 2371和1207 老是过不了 1207在电脑上还好好的 2371是超时 谢谢大侠们啊!1207:
#include"iostream"
using namespace std;
int main()
{
int n1,n2,i;
int length=0;
while(cin>>n1>>n2)
{
if(n1>n2) {t=n1;n1=n2;n2=t;}
for(i=n1;i<=n2;i++)
{
int length1=1;
int t=i;
while(t>1)
{
if(t%2) t=3*t+1;
else t=t/2;
length1++;
}
if(length1>length) length=length1;
}
cout<<n1<<" "<<n2<<" "<<length<<endl;
}
return 0;
}
2371
#include"iostream"
using namespace std;
const int MAX = 100050;
int main()
{
int n,m,i,t,j;
int a[MAX];
int b[MAX];
char s[4];
cin>>n;
for(i=0;i<n;i++)
{
cin>>a[i];
}
cin>>s;
cin>>m;
for(j=0;j<m;j++)
{
cin>>b[j];
}
for(i=1;i<n;i++)
{
t=a[i];
j=i-1;
while(j>=0 && t<a[j])
{
a[j+1]=a[j];
j--;
}
a[j+1]=t;
}
for(j=0;j<m;j++)
{
cout<<a[b[j]-1]<<endl;
}
system("pause");
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator