結果

問題 No.542 1円玉と5円玉
ユーザー dgd1724
提出日時 2017-08-12 10:41:33
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 634 bytes
コンパイル時間 649 ms
コンパイル使用メモリ 70,192 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-13 04:45:42
合計ジャッジ時間 1,285 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>

int main(void) {

	//std::ifstream inf("Text.txt");	std::cin.rdbuf(inf.rdbuf());
	int A = 0, B = 0;
	std::cin >> A >> B;
	std::vector<int> ans;

	int sum = 0;
	for (int i = 0; i <= B; i++) {
		sum += 5 * i;
		for (int j = 0; j <= A; j++) {
			sum += j;
			if (sum != 0) {
				ans.push_back(sum);
			}
			sum -= j;
		}
		sum = 0;
	}

	std::sort(ans.begin(), ans.end());
	ans.erase(std::unique(ans.begin(), ans.end()), ans.end());

	for (auto itr = ans.begin(); itr != ans.end(); itr++) {
		std::cout << *itr << std::endl;
	}

	return 0;
}
0