結果

問題 No.639 An Ordinary Sequence
ユーザー akakimidoriakakimidori
提出日時 2018-08-02 04:57:12
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 15 ms / 1,000 ms
コード長 523 bytes
コンパイル時間 956 ms
コンパイル使用メモリ 26,092 KB
実行使用メモリ 9,676 KB
最終ジャッジ日時 2023-08-30 13:00:50
合計ジャッジ時間 2,168 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
9,576 KB
testcase_01 AC 14 ms
9,576 KB
testcase_02 AC 5 ms
9,572 KB
testcase_03 AC 5 ms
9,664 KB
testcase_04 AC 5 ms
9,508 KB
testcase_05 AC 6 ms
9,560 KB
testcase_06 AC 5 ms
9,676 KB
testcase_07 AC 5 ms
9,576 KB
testcase_08 AC 5 ms
9,536 KB
testcase_09 AC 6 ms
9,664 KB
testcase_10 AC 5 ms
9,532 KB
testcase_11 AC 5 ms
9,600 KB
testcase_12 AC 5 ms
9,612 KB
testcase_13 AC 5 ms
9,576 KB
testcase_14 AC 6 ms
9,572 KB
testcase_15 AC 7 ms
9,652 KB
testcase_16 AC 15 ms
9,612 KB
testcase_17 AC 5 ms
9,576 KB
testcase_18 AC 15 ms
9,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0