結果

問題 No.1106 🦉 何事もバランスが大事
ユーザー 0w10w1
提出日時 2020-11-11 01:28:24
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,318 bytes
コンパイル時間 1,822 ms
コンパイル使用メモリ 205,920 KB
実行使用メモリ 13,996 KB
最終ジャッジ日時 2023-09-30 00:19:39
合計ジャッジ時間 5,666 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
5,424 KB
testcase_04 AC 5 ms
13,812 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
5,440 KB
testcase_10 AC 2 ms
5,524 KB
testcase_11 AC 1 ms
5,388 KB
testcase_12 AC 2 ms
7,452 KB
testcase_13 AC 2 ms
7,592 KB
testcase_14 AC 2 ms
7,552 KB
testcase_15 AC 2 ms
7,460 KB
testcase_16 AC 2 ms
7,720 KB
testcase_17 AC 2 ms
7,488 KB
testcase_18 AC 2 ms
7,556 KB
testcase_19 AC 2 ms
7,472 KB
testcase_20 AC 3 ms
9,604 KB
testcase_21 AC 3 ms
11,652 KB
testcase_22 AC 3 ms
11,544 KB
testcase_23 AC 3 ms
11,560 KB
testcase_24 AC 4 ms
13,656 KB
testcase_25 AC 4 ms
13,656 KB
testcase_26 AC 3 ms
13,584 KB
testcase_27 AC 3 ms
13,664 KB
testcase_28 AC 3 ms
13,872 KB
testcase_29 AC 3 ms
13,580 KB
testcase_30 AC 3 ms
13,616 KB
testcase_31 AC 3 ms
13,632 KB
testcase_32 AC 4 ms
13,800 KB
testcase_33 AC 4 ms
13,656 KB
testcase_34 AC 4 ms
13,772 KB
testcase_35 AC 4 ms
13,808 KB
testcase_36 AC 4 ms
13,800 KB
testcase_37 AC 3 ms
13,700 KB
testcase_38 AC 4 ms
13,712 KB
testcase_39 AC 4 ms
13,676 KB
testcase_40 AC 4 ms
13,936 KB
testcase_41 AC 3 ms
13,932 KB
testcase_42 AC 4 ms
13,692 KB
testcase_43 AC 5 ms
13,768 KB
testcase_44 AC 4 ms
13,808 KB
testcase_45 AC 4 ms
13,700 KB
testcase_46 AC 3 ms
13,700 KB
testcase_47 AC 4 ms
13,752 KB
testcase_48 AC 4 ms
13,752 KB
testcase_49 AC 4 ms
13,788 KB
testcase_50 AC 4 ms
13,728 KB
testcase_51 AC 4 ms
13,836 KB
testcase_52 AC 4 ms
13,748 KB
testcase_53 AC 4 ms
13,772 KB
testcase_54 AC 4 ms
13,816 KB
testcase_55 AC 3 ms
13,692 KB
testcase_56 AC 4 ms
13,748 KB
testcase_57 AC 4 ms
13,692 KB
testcase_58 AC 4 ms
13,752 KB
testcase_59 AC 4 ms
13,876 KB
testcase_60 AC 4 ms
13,876 KB
testcase_61 AC 4 ms
13,792 KB
testcase_62 AC 3 ms
13,772 KB
testcase_63 AC 3 ms
13,768 KB
testcase_64 AC 4 ms
13,696 KB
testcase_65 AC 4 ms
13,996 KB
testcase_66 AC 4 ms
13,764 KB
testcase_67 AC 4 ms
13,764 KB
testcase_68 AC 3 ms
13,708 KB
testcase_69 AC 4 ms
13,980 KB
testcase_70 AC 4 ms
13,812 KB
testcase_71 AC 3 ms
13,828 KB
testcase_72 AC 4 ms
13,812 KB
testcase_73 AC 4 ms
13,752 KB
testcase_74 AC 3 ms
13,724 KB
testcase_75 AC 4 ms
13,716 KB
testcase_76 AC 4 ms
13,896 KB
testcase_77 AC 4 ms
13,724 KB
testcase_78 AC 4 ms
13,792 KB
testcase_79 AC 4 ms
13,892 KB
testcase_80 AC 3 ms
13,892 KB
testcase_81 AC 3 ms
13,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int64_t N; {
    cin >> N;
  }

  vector<int> b5; {
    for (int64_t v = N; v; v /= 5) {
      b5.push_back(v % 5);
    }
    reverse(b5.begin(), b5.end());
  }

  vector<vector<int>> t(5, vector<int>(5)); {
    t[0] = { 0, +1, +2, -1, 0 };
    t[1] = { 0, +1, +2, -1, 0 };
    t[3] = { 0, +1, +2, -1, 0 };
    t[4] = { 0, +1, +2, -1, 0 };
  }

  static int64_t d[30][30][2][200][5]; {
    d[0][0][0][100][0] = 1;
    for (int n = 0; n < b5.size(); ++n) {
      for (int t = 0; t <= n; ++t) {
        for (int l = 0; l < 2; ++l) {
          for (int f = 0; f < 200; ++f) {
            for (int p = 0; p < 5; ++p) {
              if (d[n][t][l][f][p] == 0) continue;
              for (int q = 0; q < 5; ++q) {
                if (!l && b5[n] < q) continue;
                int nt = q == 2 ? t + 1 : 0;
                int c = q < 3 ? q : q == 3 ? (-1 - 4 * t) : (-4 * t);
                d[n + 1][nt][l | q < b5[n]][f + c][q] += d[n][t][l][f][p];
              }
            }
          }
        }
      }
    }
  }

  int64_t res = -1; {
    for (int t = 0; t <= b5.size(); ++t) {
      for (int q = 0; q < 5; ++q) {
        for (int l = 0; l < 2; ++l) {
          res += d[b5.size()][t][l][100][q];
        }
      }
    }
  }
  cout << res << endl;
}

0