結果

問題 No.220 世界のなんとか2
ユーザー kurome____kurome____
提出日時 2016-03-01 20:49:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,009 bytes
コンパイル時間 1,345 ms
コンパイル使用メモリ 161,844 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 19:21:16
合計ジャッジ時間 2,386 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 1 ms
4,372 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 2 ms
4,372 KB
testcase_07 AC 1 ms
4,372 KB
testcase_08 AC 1 ms
4,372 KB
testcase_09 AC 1 ms
4,372 KB
testcase_10 AC 1 ms
4,372 KB
testcase_11 AC 2 ms
4,372 KB
testcase_12 AC 2 ms
4,372 KB
testcase_13 AC 1 ms
4,372 KB
testcase_14 AC 1 ms
4,372 KB
testcase_15 AC 2 ms
4,372 KB
testcase_16 AC 1 ms
4,372 KB
testcase_17 AC 2 ms
4,372 KB
testcase_18 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:39:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |   scanf("%d ", &p);
      |   ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define RFOR(i,e,s) for(int (i)=(e)-1;(i)>=(int)(s);(i)--)
#define RREP(i,e) RFOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef pair<int, int> PII;
typedef priority_queue<int> PQI;
typedef priority_queue<PII> PQII;

const double EPS = 1e-10;
const int P = 19;
int p;
ll dp[P+1][2][3][2];  //poss, less, mod 3, has 3

ll calc(string x) {
  int n = (int)x.size();
  memset(dp, 0, sizeof(dp));
  dp[0][0][0][0] = 1;
  REP(i,n) REP(j,2) REP(k,3) REP(l,2) {
    int lim = j ? 9 : x[i]-'0';
    REP(d,lim+1) dp[i+1][j || d<lim][(k*10+d)%3][l || d==3] += dp[i][j][k][l];
  }
  ll res = 0;
  REP(j,2) REP(k,3) REP(l,2)
    if (!k || l) res += dp[n][j][k][l];
  return res;
}

int main() {
  scanf("%d ", &p);
  string x = "1";
  REP(i,p) x += '0';
  printf("%lld\n", calc(x)-1);
  return 0;
}
0