Submission #2997109


Source Code Expand

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

int main() {
	int n;
	cin >> n;

	int p = 0, a = 0, b = 0, c = 0, d = 0;

	if (n >= 8) {
		for (int i = n; i >= 8; i -= 8) {
			a++;
			p++;
		}
		n = n % 8;
	}
	if (n >= 4) {
		for (int i = n; i >= 4; i -= 4) {
			b++;
			p++;
		}
		n = n % 4;
	}
	if (n >= 2) {
		for (int i = n; i >= 2; i -= 2) {
			c++;
			p++;
		}
		n = n % 2;
	}
	if (n >= 1) {
		for (int i = n; i >= 1; i -= 1) {
			d++;
			p++;
		}
		n = n % 1;
	}

	cout << p << endl;
	for (int i = 0; i < a; i++) {
		cout << 8 << endl;
	}
	for (int i = 0; i < b; i++) {
		cout << 4 << endl;
	}
	for (int i = 0; i < c; i++) {
		cout << 2 << endl;
	}
	for (int i = 0; i < d; i++) {
		cout << 1 << endl;
	}

	return 0;
}

Submission Info

Submission Time
Task A - 足し算
User Today
Language C++14 (GCC 5.4.1)
Score 100
Code Size 789 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 2
AC × 10
Set Name Test Cases
Sample subtask0_sample_01.txt, subtask0_sample_02.txt
All subtask0_sample_01.txt, subtask0_sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt AC 1 ms 256 KB
subtask0_sample_02.txt AC 1 ms 256 KB
subtask1_01.txt AC 1 ms 256 KB
subtask1_02.txt AC 1 ms 256 KB
subtask1_03.txt AC 1 ms 256 KB
subtask1_04.txt AC 1 ms 256 KB
subtask1_05.txt AC 1 ms 256 KB
subtask1_06.txt AC 1 ms 256 KB
subtask1_07.txt AC 1 ms 256 KB
subtask1_08.txt AC 1 ms 256 KB