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:help!其他的方法我就想不到!想到的又超时!答案一定是对的!In Reply To:help!其他的方法我就想不到!想到的又超时!答案一定是对的! Posted by:plumage at 2005-04-23 22:57:34 > #include<iostream.h> > #include<fstream.h>// > > void main() > { > fstream fin("in.txt",ios::in||ios::out);// > fstream fout("out.txt",ios::out);// > unsigned long input,population,m,dis,m1,t,tt;//; > while(1) > { > // fin>>input; > cin>>input; > > > if(input==0) > return; > > > m=input+1;//initialize m > > while(1) > { > population=2*input;//the number of people > dis=0; > > while(1) > { > m1=m-dis; > > m1%=population; > > if(m1>input||m1==0) > { > dis=population-m1; > if(m1==0) > dis=0; > > population--; > > } > else > break; > if(population==input) > break; > } > if(population==input) > break; > > m++;//selfadding > // > > // m+=(input+1); > /* > t=m/population; > tt=m%population; > if(tt<=input&&tt>0) > m=t*population+input+1; > */ > } > cout<<m<<endl; > } > > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator