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 |
咋也贴个高质量代码#include <stdio.h> #include<iostream> #include<math.h> using namespace std; int main() { int T; while (cin>>T){ int level = pow((double)(2*T), 0.5); if ((level + 1)*level >= (2 * T)) level--; int pre_total = (level + 1)*level / 2; int last_total = T - pre_total; level++; int fenzi = 1, fenmu = level; fenmu -= last_total-1; fenzi += last_total-1; if (level%2==0){ cout << "TERM " << T << " IS " << fenzi << "/" << fenmu << endl; } else cout << "TERM " << T << " IS " << fenmu << "/" << fenzi << 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