Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
循环找在第几排都能过。。。好水。。。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator