結果
| 問題 | No.639 An Ordinary Sequence |
| コンテスト | |
| ユーザー |
akakimidori
|
| 提出日時 | 2018-08-02 04:57:12 |
| 言語 | C90 (gcc 15.2.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 1,000 ms |
| コード長 | 523 bytes |
| 記録 | |
| コンパイル時間 | 384 ms |
| コンパイル使用メモリ | 39,640 KB |
| 最終ジャッジ日時 | 2026-02-24 00:57:56 |
|
ジャッジサーバー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