結果

問題 No.639 An Ordinary Sequence
コンテスト
ユーザー e869120
提出日時 2018-01-26 22:23:40
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 1,000 ms
+ 547µs
コード長 476 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 468 ms
コンパイル使用メモリ 109,372 KB
実行使用メモリ 9,872 KB
最終ジャッジ日時 2026-10-10 03:41:03
合計ジャッジ時間 1,695 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <cmath>
#include <tuple>
using namespace std;
#pragma warning (disable: 4996)

map<long long, long long>M;

long long sum(long long p) {
	if (p == 0) return 1;
	if (M[p] >= 1) return M[p] - 1;
	long long R = sum(p / 3) + sum(p / 5);
	M[p] = R + 1;
	return R;
}

int main() {
	long long n; cin >> n;
	cout << sum(n) << endl;
	return 0;
}
0