답안 #81856

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
81856 2018-10-27T11:59:02 Z zzee Nadan (COCI18_nadan) C++11
50 / 50
3 ms 604 KB
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cctype>

using namespace std;

int main()
{
	int k,n,f,p,m,x,x1,g;
	cin >> k >> n;
	f = 0;
	for (int i = 1; i < n+1 ; i = i + 1){
		f = f + i;
//		cout << f << endl;
	}
	g = 0;
	if (f>k)
		for (int i = 0;i<f-k;i=i+1){
			cout << 1<<endl;
			g = g + 1;
		}
	m = 1;
	x1 = 0;
	for (int i = g; i < n - 1 ; i = i + 1){
		x =  m;
		cout << m << endl;
		m = m + 1;
		x1 = x1 + x;
	}
	cout << k - x1 - g;
	return 0;

}

Compilation message

nadan.cpp: In function 'int main()':
nadan.cpp:11:12: warning: unused variable 'p' [-Wunused-variable]
  int k,n,f,p,m,x,x1,g;
            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 548 KB Output is correct
4 Correct 2 ms 548 KB Output is correct
5 Correct 2 ms 548 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
7 Correct 2 ms 548 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 3 ms 548 KB Output is correct
10 Correct 2 ms 604 KB Output is correct