結果

問題 No.1106 🦉 何事もバランスが大事
ユーザー 👑 emthrmemthrm
提出日時 2020-07-03 23:00:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 1,666 bytes
コンパイル時間 2,423 ms
コンパイル使用メモリ 216,164 KB
実行使用メモリ 15,368 KB
最終ジャッジ日時 2023-10-17 06:02:07
合計ジャッジ時間 8,856 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
15,368 KB
testcase_01 AC 57 ms
15,368 KB
testcase_02 AC 56 ms
15,368 KB
testcase_03 AC 56 ms
15,368 KB
testcase_04 AC 56 ms
15,368 KB
testcase_05 AC 57 ms
15,368 KB
testcase_06 AC 56 ms
15,368 KB
testcase_07 AC 57 ms
15,368 KB
testcase_08 AC 57 ms
15,368 KB
testcase_09 AC 57 ms
15,368 KB
testcase_10 AC 57 ms
15,368 KB
testcase_11 AC 57 ms
15,368 KB
testcase_12 AC 57 ms
15,368 KB
testcase_13 AC 56 ms
15,368 KB
testcase_14 AC 57 ms
15,368 KB
testcase_15 AC 56 ms
15,368 KB
testcase_16 AC 56 ms
15,368 KB
testcase_17 AC 57 ms
15,368 KB
testcase_18 AC 57 ms
15,368 KB
testcase_19 AC 56 ms
15,368 KB
testcase_20 AC 56 ms
15,368 KB
testcase_21 AC 56 ms
15,368 KB
testcase_22 AC 57 ms
15,368 KB
testcase_23 AC 56 ms
15,368 KB
testcase_24 AC 56 ms
15,368 KB
testcase_25 AC 57 ms
15,368 KB
testcase_26 AC 56 ms
15,368 KB
testcase_27 AC 56 ms
15,368 KB
testcase_28 AC 56 ms
15,368 KB
testcase_29 AC 56 ms
15,368 KB
testcase_30 AC 57 ms
15,368 KB
testcase_31 AC 56 ms
15,368 KB
testcase_32 AC 56 ms
15,368 KB
testcase_33 AC 56 ms
15,368 KB
testcase_34 AC 56 ms
15,368 KB
testcase_35 AC 56 ms
15,368 KB
testcase_36 AC 56 ms
15,368 KB
testcase_37 AC 56 ms
15,368 KB
testcase_38 AC 57 ms
15,368 KB
testcase_39 AC 56 ms
15,368 KB
testcase_40 AC 56 ms
15,368 KB
testcase_41 AC 56 ms
15,368 KB
testcase_42 AC 57 ms
15,368 KB
testcase_43 AC 57 ms
15,368 KB
testcase_44 AC 56 ms
15,368 KB
testcase_45 AC 56 ms
15,368 KB
testcase_46 AC 56 ms
15,368 KB
testcase_47 AC 56 ms
15,368 KB
testcase_48 AC 56 ms
15,368 KB
testcase_49 AC 56 ms
15,368 KB
testcase_50 AC 56 ms
15,368 KB
testcase_51 AC 56 ms
15,368 KB
testcase_52 AC 56 ms
15,368 KB
testcase_53 AC 56 ms
15,368 KB
testcase_54 AC 56 ms
15,368 KB
testcase_55 AC 56 ms
15,368 KB
testcase_56 AC 57 ms
15,368 KB
testcase_57 AC 56 ms
15,368 KB
testcase_58 AC 56 ms
15,368 KB
testcase_59 AC 56 ms
15,368 KB
testcase_60 AC 56 ms
15,368 KB
testcase_61 AC 56 ms
15,368 KB
testcase_62 AC 56 ms
15,368 KB
testcase_63 AC 56 ms
15,368 KB
testcase_64 AC 56 ms
15,368 KB
testcase_65 AC 57 ms
15,368 KB
testcase_66 AC 56 ms
15,368 KB
testcase_67 AC 56 ms
15,368 KB
testcase_68 AC 56 ms
15,368 KB
testcase_69 AC 56 ms
15,368 KB
testcase_70 AC 56 ms
15,368 KB
testcase_71 AC 56 ms
15,368 KB
testcase_72 AC 56 ms
15,368 KB
testcase_73 AC 56 ms
15,368 KB
testcase_74 AC 56 ms
15,368 KB
testcase_75 AC 56 ms
15,368 KB
testcase_76 AC 56 ms
15,368 KB
testcase_77 AC 56 ms
15,368 KB
testcase_78 AC 56 ms
15,368 KB
testcase_79 AC 55 ms
15,368 KB
testcase_80 AC 55 ms
15,368 KB
testcase_81 AC 56 ms
15,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  const int X = 26;
  ll n; cin >> n;
  ++n;
  vector<int> five(X, 0);
  ll tmp = n;
  REP(i, X) {
    five[i] = tmp % 5;
    tmp /= 5;
  }
  vector dp(X + 1, vector(X * 2 + 1, vector(X * 2 + 1, vector(2, vector(2, 0LL)))));
  dp[0][0][0][false][false] = 1;
  REP(i, X) REP(j, X * 2 + 1) REP(k, X * 2 + 1) REP(l, 2) REP(m, 2) {
    REP(w, 5) {
      REP(a, 3) REP(b, 3) {
        if (j + a > X * 2 || k + b > X * 2 || a + b >= 3 || (a == 1 && b == 1)) continue;
        int val = w + m + a;
        if (val % 5 != b) continue;
        int nx_l = w < five[i] || (w == five[i] && l);
        dp[i + 1][j + a][k + b][nx_l][val >= 5] += dp[i][j][k][l][m];
      }
    }
  }
  ll ans = 0;
  FOR(j, 1, X * 2 + 1) ans += dp[X][j][j][true][false] + dp[X][j][j - 1][true][true];
  cout << ans << '\n';
  return 0;
}
0