結果
| 問題 | No.639 An Ordinary Sequence | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-03-24 08:45:34 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 12 ms / 1,000 ms | 
| コード長 | 470 bytes | 
| コンパイル時間 | 200 ms | 
| コンパイル使用メモリ | 27,776 KB | 
| 実行使用メモリ | 9,444 KB | 
| 最終ジャッジ日時 | 2025-01-02 02:24:05 | 
| 合計ジャッジ時間 | 946 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 17 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |     scanf("%lld",&N);
      |     ~~~~~^~~~~~~~~~~
            
            ソースコード
#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));
}
            
            
            
        