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 KatrineYang at 2016-06-08 22:13:28 on Problem 1032
//============================================================================
// Name        : main1032.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cmath>
using namespace std;

int main() {
        int N;
        cin >> N;
        int n = (int)((-1+sqrt(8*N+9.0))/2);
        //cout << n;
        int dif = N + 1 - n*(n+1)/2;
        if(dif < n){
        	for(int i = 2; i < n+2; i++){
        		if(i != n+1-dif) cout << i << " ";
        	}
        }
        else{
        	for(int i = 3; i < n+1; i++){
        		cout << i << " ";
        	}
        	cout << n+2;
        }
	//cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
	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