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

最简单的暴力解法,附代码

Posted by TOBENO1 at 2013-10-22 17:55:59 on Problem 1844
#include<iostream>
using namespace std;

int main(){
	int n;
	while(cin>>n){
		int i,j,k,s;
		for(i=1;;i++){
			for(j=1;;j++){
				if(n==i*(1+i)/2-2*j){
					cout<<i<<endl;
					break;
				}
				if(i*(1+i)/2-2*j<0)
					break;
			}
			if(n==i*(1+i)/2-2*j)
			break;
		}
		
	}
	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