結果

問題 No.220 世界のなんとか2
ユーザー togatogatogatoga
提出日時 2015-08-18 23:46:25
言語 C++11
(gcc 11.4.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,427 bytes
コンパイル時間 1,328 ms
コンパイル使用メモリ 145,356 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 12:56:49
合計ジャッジ時間 4,457 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘ll solve()’:
main.cpp:61:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^

ソースコード

diff #

#include <bits/stdc++.h>

#define mp       make_pair
#define mt	 make_tuple
#define pb       push_back
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    pair<int,int>      pii;
typedef    pair<long,long>    pll;

const int INF=1<<29;
const double EPS=1e-9;
const int MOD = 100000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int N;
ll dp[21][3][2][2];//pos, div, three, less
ll solve(){
  memset(dp, 0, sizeof(dp));
  dp[0][0][0][0] = 1;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < 3; j++){
      for (int k = 0; k < 2; k++){
	for (int m = 0; m < 2; m++){//0 equal 1 determine less
	  int digit = (i == 0 ? 1 : 0);
	  if (dp[i][j][k][m] == 0)continue;
	  for (int l = 0; l <= 9; l++){
	    if (m == 0){
	      if (l > digit)continue;
	      if (l == digit){
		dp[i + 1][(10 * j + l) % 3][k][0] += dp[i][j][k][m];
	      }else{
		dp[i + 1][(10 * j + l) % 3][k][1] += dp[i][j][k][m];
	      }
	    }else{
	      if (l == 3){
		dp[i + 1][(10 * j + l) % 3][1][m] += dp[i][j][k][m];
	      }else{
		dp[i + 1][(10 * j + l) % 3][k][m] += dp[i][j][k][m];
	      }
	    }
	  }
	}
      }
    }
  }
  ll res = 0;

  for (int j = 0; j < 2; j++){
    res += dp[N][0][1][j];
    res += dp[N][1][1][j];
    res += dp[N][2][1][j];
    res += dp[N][0][0][j];
  }

  cout << res - 1<< endl;
}
int main(){
  cin >> N;
  N++;
  solve();
}
0