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 lantao at 2009-05-26 15:43:39 on Problem 1969
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main()
{
	int n,num,temp;
	int x,y;
	while (scanf("%d", &num) != EOF)
	{
		for (n = 1 ; n * (n+1) / 2 < num ; ++n);
		x = n - (num - n*(n-1)/2-1);
		y = n+1-x;
		if (!(n%2))
		{
			temp = x ; x = y ; y = temp;
		}
		cout<<"TERM "<<num<<" IS "<<x<<"/"<<y<<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