結果

問題 No.220 世界のなんとか2
ユーザー akakimidoriakakimidori
提出日時 2019-02-08 11:24:12
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 649 bytes
コンパイル時間 1,190 ms
コンパイル使用メモリ 30,140 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 23:12:59
合計ジャッジ時間 1,978 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 0 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 0 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 0 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 0 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 0 ms
4,376 KB
testcase_16 AC 0 ms
4,376 KB
testcase_17 AC 0 ms
4,380 KB
testcase_18 AC 0 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

#define POS(i,j,k) ((((i)&1)*3+((j)%3))*2+(k))

void run(void){
  int p;
  scanf("%d",&p);
  int64 *dp=(int64 *)calloc(2*3*2,sizeof(int64));
  dp[POS(0,0,0)]=1;
  for(int i=0;i<p;i++){
    int j,k;
    for(j=0;j<3;j++) for(k=0;k<2;k++) dp[POS(i+1,j,k)]=0;
    for(j=0;j<3;j++){
      for(k=0;k<2;k++){
	for(int l=0;l<10;l++){
	  dp[POS(i+1,10*j+l,k||(l==3))]+=dp[POS(i,j,k)];
	}
      }
    }
  }
  int64 ans=0;
  for(int i=0;i<3;i++){
    for(int j=0;j<2;j++){
      ans+=(i==0 || j)?dp[POS(p,i,j)]:0;
    }
  }
  printf("%lld\n",ans-1);
}

int main(void){
  run();
  return 0;
}
0