結果

問題 No.634 硬貨の枚数1
ユーザー 👑 jupirojupiro
提出日時 2020-01-17 18:40:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,243 bytes
コンパイル時間 947 ms
コンパイル使用メモリ 115,292 KB
実行使用メモリ 13,216 KB
最終ジャッジ日時 2023-09-07 22:19:38
合計ジャッジ時間 3,598 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,520 KB
testcase_15 AC 4 ms
11,768 KB
testcase_16 AC 3 ms
7,688 KB
testcase_17 AC 4 ms
9,636 KB
testcase_18 AC 4 ms
7,700 KB
testcase_19 AC 4 ms
11,736 KB
testcase_20 AC 5 ms
12,336 KB
testcase_21 AC 5 ms
12,876 KB
testcase_22 AC 4 ms
11,732 KB
testcase_23 AC 3 ms
7,628 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 3 ms
7,512 KB
testcase_36 AC 4 ms
9,620 KB
testcase_37 AC 4 ms
7,564 KB
testcase_38 AC 2 ms
4,504 KB
testcase_39 AC 4 ms
11,900 KB
testcase_40 AC 4 ms
9,852 KB
testcase_41 AC 4 ms
9,744 KB
testcase_42 AC 4 ms
11,728 KB
testcase_43 AC 3 ms
7,560 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 2 ms
4,436 KB
testcase_47 AC 5 ms
13,216 KB
testcase_48 AC 1 ms
4,380 KB
testcase_49 AC 3 ms
4,504 KB
testcase_50 AC 5 ms
13,172 KB
testcase_51 AC 3 ms
4,700 KB
testcase_52 AC 1 ms
4,376 KB
testcase_53 AC 2 ms
4,380 KB
testcase_54 AC 2 ms
4,376 KB
testcase_55 AC 5 ms
13,048 KB
testcase_56 AC 5 ms
13,044 KB
testcase_57 AC 5 ms
13,024 KB
testcase_58 AC 5 ms
12,860 KB
testcase_59 AC 5 ms
12,888 KB
testcase_60 AC 5 ms
12,984 KB
testcase_61 AC 5 ms
12,832 KB
testcase_62 AC 5 ms
12,760 KB
testcase_63 AC 5 ms
12,944 KB
testcase_64 AC 5 ms
12,868 KB
testcase_65 AC 5 ms
13,012 KB
testcase_66 AC 5 ms
13,148 KB
testcase_67 AC 5 ms
13,008 KB
testcase_68 AC 5 ms
13,028 KB
testcase_69 AC 5 ms
13,000 KB
testcase_70 AC 5 ms
12,996 KB
testcase_71 AC 5 ms
12,952 KB
testcase_72 AC 5 ms
13,028 KB
testcase_73 AC 5 ms
12,740 KB
testcase_74 AC 5 ms
12,784 KB
testcase_75 AC 5 ms
12,664 KB
testcase_76 AC 1 ms
4,380 KB
testcase_77 AC 3 ms
5,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


bool exist[10000500];
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	ll N; scanf("%lld", &N);
	vector<ll> coin;
	for (ll i = 1; i * (i + 1) / 2 <= N; i++) {
		exist[i * (i + 1) / 2] = true;
		coin.push_back(i * (i + 1) / 2);
	}
	if (exist[N]) puts("1");
	else {
		for (ll e : coin) {
			if (exist[N - e]) {
				puts("2");
				return 0;
			}
		}
		puts("3");
	}
	return 0;
}
0