結果
| 問題 |
No.639 An Ordinary Sequence
|
| コンテスト | |
| ユーザー |
akakimidori
|
| 提出日時 | 2018-08-02 04:57:12 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 1,000 ms |
| コード長 | 523 bytes |
| コンパイル時間 | 2,205 ms |
| コンパイル使用メモリ | 37,984 KB |
| 実行使用メモリ | 9,820 KB |
| 最終ジャッジ日時 | 2025-01-02 02:32:19 |
| 合計ジャッジ時間 | 2,953 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 |
ソースコード
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
typedef long long int int64;
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
const int m=1000000;
int64 *a=NULL;
int64 calc(int64 n){
if(n<=m) return a[n];
return calc(n/3)+calc(n/5);
}
void run(void){
int64 n;
scanf("%lld",&n);
a=(int64 *)malloc(sizeof(int64)*(m+1));
a[0]=1;
int i;
for(i=1;i<=m;i++) a[i]=a[i/3]+a[i/5];
printf("%lld\n",calc(n));
}
int main(void){
run();
return 0;
}
akakimidori