結果

問題 No.639 An Ordinary Sequence
ユーザー square1001square1001
提出日時 2017-08-16 16:40:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 306 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 64,692 KB
実行使用メモリ 11,416 KB
最終ジャッジ日時 2023-08-30 12:42:52
合計ジャッジ時間 1,606 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
11,104 KB
testcase_01 AC 12 ms
11,156 KB
testcase_02 AC 6 ms
11,416 KB
testcase_03 AC 6 ms
11,160 KB
testcase_04 AC 6 ms
11,160 KB
testcase_05 AC 6 ms
11,164 KB
testcase_06 AC 6 ms
11,184 KB
testcase_07 AC 7 ms
11,160 KB
testcase_08 AC 7 ms
11,304 KB
testcase_09 AC 7 ms
11,108 KB
testcase_10 AC 6 ms
11,104 KB
testcase_11 AC 6 ms
11,180 KB
testcase_12 AC 6 ms
11,188 KB
testcase_13 AC 6 ms
11,360 KB
testcase_14 AC 6 ms
11,192 KB
testcase_15 AC 9 ms
11,188 KB
testcase_16 AC 12 ms
11,188 KB
testcase_17 AC 6 ms
11,184 KB
testcase_18 AC 12 ms
11,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
long long n, a[1000009];
long long solve(long long x) {
	if (x <= 1000000) return a[x];
	return solve(x / 3) + solve(x / 5);
}
int main() {
	a[0] = 1;
	for (int i = 1; i <= 1000000; i++) a[i] = a[i / 3] + a[i / 5];
	cin >> n;
	cout << solve(n) << endl;
	return 0;
}
0