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

Why wrong answer?

Posted by xinyuan at 2007-03-27 20:40:44 on Problem 1969
#include<math.h>
#include<stdio.h>
#define N "TERM %d IS %d/%d\n"
void main(){
long n,k,j;
while(scanf("%d",&n)!=EOF)
{
k=sqrt(n)+1;
j=n-k*(k+1)/2;
while(j<0){k--;j=n-k*(k+1)/2;}
while(j>k){k++;j-=k;}
if(!j)printf(N,n,k,1);
else {
      if(k%2)printf(N,n,j,k-j+2);                                   
      else printf(N,n,k+2-j,j);
     }
}
          }

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