結果

問題 No.220 世界のなんとか2
ユーザー ttakanottakano
提出日時 2017-12-05 00:23:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 834 bytes
コンパイル時間 2,830 ms
コンパイル使用メモリ 145,044 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-18 21:56:33
合計ジャッジ時間 3,602 ms
ジャッジサーバーID
(参考情報)
judge9 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int p;
ll dp[30][2][2][3];

int main(){
  cin>>p;
  dp[0][0][0][0]=1;
  REP(i,p+1){
    REP(j,2){
      int lim;
      if(j==1)lim=9;
      else if(j==0&&i==0)lim=1;
      else lim=0;
      REP(k,2){
        REP(l,3){
          REP(m,lim+1){
            dp[i+1][j||m<lim][k||m==3][(l+m)%3]+=dp[i][j][k][l];
          }
        }
      }
    }
  }
  ll ans=0;
  REP(j,2)REP(k,2)REP(l,3){
    if(k==1||l==0){
      ans+=dp[p+1][j][k][l];
    }
  }
  print(ans-1);
}
0