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

找规律找规律,贴贴代码O(∩_∩)O~话说我不喜欢找规律⊙﹏⊙b汗

Posted by TSERROF at 2012-08-07 14:08:31 on Problem 1969
#include <cstdio>
int main()
{
	int si=1,sj=1;
	int f;
	while(scanf("%d",&f)!=EOF)
	{
		int level=1;
		int row,col;
		while ((level+1)*level/2 < f)++level;
		if(level%2==0)
		{
			row=1,col=level;
			int head=2;
			for (int i=1,j=5;i<level/2;++i)
			{
				head+=j;
				j+=4;
			}
			while(f>head++)
			{
				++row;
				--col;
			}
		}
		else
		{
			row=1,col=level;
			int tail=(level+1)*level/2;
			while(tail-- >f)
			{
				++row;
				--col;
			}
		}
		printf("TERM %d IS %d/%d\n",f,row,col);
	}
	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