結果

問題 No.1106 🦉 何事もバランスが大事
ユーザー IKyoproIKyopro
提出日時 2020-07-03 23:45:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,316 bytes
コンパイル時間 2,085 ms
コンパイル使用メモリ 203,768 KB
実行使用メモリ 12,068 KB
最終ジャッジ日時 2023-10-17 06:28:18
合計ジャッジ時間 7,872 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

ll dp[30][100][100][2][2] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll five = 1;
    while(5*five<=N) five *= 5;
    string S = "";
    ll n = N;
    while(five){
        ll a = n/five;
        S += (char) '0'+a;
        n -= five*a;
        five /= 5;
    }
    cerr << S << "\n";
    int M = S.size();
    int A = 60;
    dp[0][0][0][0][0] = 1;
    for(int i=0;i<M;i++) for(int l=0;l<A;l++) for(int r=0;r<A;r++) for(int k=0;k<2;k++) for(int j=0;j<2;j++){
        int x = S[i]-'0';
        for(int n=0;n<5;n++){
            int nk = (k || n<x);
            if(!k && n>x) continue;
            for(int a=0;a<3;a++) for(int b=0;b<3;b++){
                if(a+b>2) continue;
                if(a==b && a>0) continue;
                int nl = l+a,nr = r+b;
                int nj = 0;
                if(a+5*j-b==n) nj = 0;
                else if(a+5*j-b==n+1) nj = 1;
                else continue;
                dp[i+1][nl][nr][nk][nj] += dp[i][l][r][k][j];
            }
        }
    }
    ll ans = 0;
    for(int i=0;i<A;i++) ans += dp[M][i][i][0][0]+dp[M][i][i][1][0];
    cout << ans-1 << "\n";
}
0