結果

問題 No.2017 Mod7 Parade
ユーザー HaaHaa
提出日時 2022-07-22 21:52:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 1,074 bytes
コンパイル時間 1,972 ms
コンパイル使用メモリ 167,364 KB
実行使用メモリ 4,740 KB
最終ジャッジ日時 2023-09-17 09:44:34
合計ジャッジ時間 4,702 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 142 ms
4,376 KB
testcase_04 AC 95 ms
4,376 KB
testcase_05 AC 71 ms
4,376 KB
testcase_06 AC 155 ms
4,380 KB
testcase_07 AC 21 ms
4,376 KB
testcase_08 AC 89 ms
4,380 KB
testcase_09 AC 35 ms
4,376 KB
testcase_10 AC 89 ms
4,376 KB
testcase_11 AC 123 ms
4,380 KB
testcase_12 AC 108 ms
4,376 KB
testcase_13 AC 179 ms
4,576 KB
testcase_14 AC 179 ms
4,708 KB
testcase_15 AC 179 ms
4,740 KB
testcase_16 AC 179 ms
4,684 KB
testcase_17 AC 179 ms
4,620 KB
testcase_18 AC 173 ms
4,720 KB
testcase_19 AC 37 ms
4,568 KB
testcase_20 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
template<typename T> bool chmax(T &x, const T &y) {return (x<y)?(x=y,true):false;};
template<typename T> bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;};
constexpr ll MOD=1000000007;
constexpr ll INF=2e18;

ll power(ll x, ll y, ll p){
    x%=p;
    ll ret=1;
    while(y){
        if(y&1) ret=ret*x%p;
        x=x*x%p;
        y>>=1;
    }
    return ret;
}
ll divid(ll x, ll y, ll p){
    x%=p;
    return x*power(y,p-2,p)%p;
}

int main(){
    int k; cin >> k;
    VI d(k), l(k);
    REP(i,k) cin >> d[i] >> l[i];
    ll d9=divid(1,9,7);
    VI dp(7,0); dp[0]=1;
    REP(i,k){
        ll m=(power(10,l[i],7)-1+7)*d9%7*d[i]%7;
        VI ndp(7,0);
        REP(j,7) ndp[(j*power(10,l[i],7)+m)%7]=dp[j];
        REP(j,7) dp[j]=(dp[j]+ndp[j])%MOD;
    }
    ll ans=0;
    REP(i,7) ans=(ans+dp[i]*i%MOD)%MOD;
    cout << ans << endl;
    return 0;
}
0