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

100題留念~

Posted by ytlau9 at 2011-01-09 20:51:08 on Problem 1969
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#define LL long long
int main(){
        LL n,addup,son,parent,last;
        while(scanf("%lld", &n)!=EOF){
                LL sum =0;
                for(int i=1;;i++){
                        sum+=i;
                        if(sum >=n){last= sum-i; addup = i+1; break;}
                }
                if(addup%2==0){
                        parent = n - last;
                        son = addup-parent;
                }
                else{
                        son = n - last;
                        parent = addup-son;
                }
                printf("TERM %lld IS %lld/%lld\n", n,son,parent);
        }
        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