結果

問題 No.2017 Mod7 Parade
ユーザー milanis48663220milanis48663220
提出日時 2022-07-22 22:03:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,688 bytes
コンパイル時間 1,389 ms
コンパイル使用メモリ 127,112 KB
実行使用メモリ 50,248 KB
最終ジャッジ日時 2023-09-17 10:07:33
合計ジャッジ時間 3,667 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 108 ms
50,048 KB
testcase_19 AC 103 ms
50,128 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#include <atcoder/modint>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

using mint = atcoder::modint1000000007;

ostream& operator<<(ostream& os, const mint& m){
    os << m.val();
    return os;
}

mint pow(mint a, ll n) {
    assert(n >= 0);
	mint ans = 1;
    while (n > 0) {
        if (n&1) ans = ans*a;
        a = a*a;
        n >>= 1;
    }
	return ans;
}

ll mod_pow(ll a, ll n, ll mod) {
    ll ans = 1;
    while (n > 0) {
        if (n&1) ans = (ans*a)%mod;
        a = (a*a)% mod;
        n >>= 1;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int k; cin >> k;
    vector<int> d(k), l(k);
    for(int i = 0; i < k; i++){
        cin >> d[i] >> l[i];
    }
    auto dp = vec3d(k+1, 6, 7, mint(0));
    dp[k][0][0] = 1;
    vector<int> rem(6);
    for(int i = 0; i < 6; i++) rem[i] = mod_pow(10, i, 7);
    for(int i = k-1; i >= 0; i--){
        int len = l[i]%6;
        int cur = d[i]%7;
        for(int j = 1; j < len; j++){
            cur = cur*10+d[i];
            cur %= 7;
        }
        for(int j = 0; j < 6; j++){
            for(int p = 0; p <= 6; p++){
                // 使わない
                dp[i][j][p] += dp[i+1][j][p];
                // 使う
                int rr = (p+cur*rem[j])%7;
                dp[i][(j+len)%6][rr] += dp[i+1][j][p];
            }
        }
    }
    mint ans = 0;
    for(int j = 0; j < 6; j++){
        for(int k = 0; k < 7; k++){
            ans += dp[0][j][k]*k;
        }
    }
    cout << ans << endl;
}
0