結果
| 問題 | No.639 An Ordinary Sequence |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-03-24 08:45:34 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 1,000 ms |
| コード長 | 470 bytes |
| 記録 | |
| コンパイル時間 | 208 ms |
| コンパイル使用メモリ | 38,400 KB |
| 実行使用メモリ | 11,648 KB |
| 最終ジャッジ日時 | 2026-06-05 19:40:32 |
| 合計ジャッジ時間 | 1,337 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 |
ソースコード
#include <stdio.h>
#define CACHE_SIZE 1000000
long long int dp[CACHE_SIZE];
long long int calc (long long int N){
if(N < CACHE_SIZE){
if(dp[N] != -1) return dp[N];
return (dp[N] = calc(N/3)+calc(N/5));
}else{
return calc(N/3)+calc(N/5);
}
}
int main(void){
// Your code here!
for(long long int i = 0; i < CACHE_SIZE; i++) dp[i] = -1;
dp[0]=1;
long long int N;
scanf("%lld",&N);
printf("%lld\n", calc(N));
}