Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

咋也贴个高质量代码

Posted by 1403121865 at 2016-05-18 17:40:56 on Problem 1969
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator