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: 0msACIn Reply To: 0msAC Posted by:ylllxw08 at 2009-08-15 23:16:23 佩服, if(int==double) 你也敢用... > #include<iostream> > #include<math.h> > using namespace std; > int fun(int n) > { > double k; > k=sqrt(double(2)*n+0.25)-0.5; > if(k==int(k)) > return int(k)-1; > else > return int(k); > } > int main() > { > int k,m,n; > while(cin>>n) > { > k=fun(n); > m=n-k*(k+1)/2; > if(k%2) > cout<<"TERM "<<n<<" IS "<<m<<'/'<<k+2-m<<endl; > else > cout<<"TERM "<<n<<" IS "<<k+2-m<<'/'<<m<<endl; > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator