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

OK了

Posted by ecust_xuchen at 2008-01-29 23:32:54 on Problem 1969
#include<iostream>
#include<stdio.h>
using namespace std;
void judge(long int m,long int *x,long int *y){
	int i;
	for(i=1;;i++){
		if(1+(i-1)*i/2<=m&&i+(i-1)*i/2>=m) break;
	}
	m=m-(i-1)*i/2;
	if(i%2==1){
		*x=m;
		*y=i-m+1;
	}
	else{
		*y=m;
		*x=i-m+1;
	}
} 
int main(){
	long int x,y,m;
	while(scanf("%ld",&m)!=EOF){
		judge(m,&x,&y);
		cout<<"TERM "<<m<<" IS "<<y<<"/"<<x<<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