結果

問題 No.634 硬貨の枚数1
ユーザー ldsyb
提出日時 2018-01-20 00:35:22
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 1,524 ms
コンパイル使用メモリ 167,632 KB
実行使用メモリ 81,408 KB
最終ジャッジ日時 2024-12-25 20:41:00
合計ジャッジ時間 9,046 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 75
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	vector<int64_t> v(10000001);
	for (int64_t i = 1; i <= 10000001; i++) {
		v[i - 1] = i * (i + 1) / 2;
	}
	int64_t n;
	cin >> n;
	{
		auto itr = lower_bound(v.begin(), v.end(), n);
		if (itr != v.end() && *itr == n) {
			cout << 1 << endl;
			return 0;
		}
	}
	for (auto &i : v) {
		if (n < i) {
			break;
		}
		auto itr = lower_bound(v.begin(), v.end(), n - i);
		if (itr != v.end() && i + *itr == n) {
			cout << 2 << endl;
			return 0;
		}
	}
	cout << 3 << endl;
	return 0;
}
0