結果
問題 | No.2017 Mod7 Parade |
ユーザー |
![]() |
提出日時 | 2022-07-22 23:04:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 50 ms / 2,000 ms |
コード長 | 665 bytes |
コンパイル時間 | 1,904 ms |
コンパイル使用メモリ | 195,276 KB |
最終ジャッジ日時 | 2025-01-30 12:58:45 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; ll dp[100100][7]; const int MOD=1e9+7; ll A[]={1,3,2,6,4,5}; ll B[]={0,1,4,6,5,2}; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int k; cin>>k; vector<ll> D(k),L(k); rep(i,k) cin>>D[i]>>L[i]; dp[0][0]=1; for(int i=0;i<k;i++){ for(int j=0;j<7;j++){ ll t=(j*A[L[i]%6]+D[i]*B[L[i]%6])%7; dp[i+1][t]=(dp[i+1][t]+dp[i][j])%MOD; dp[i+1][j]=(dp[i+1][j]+dp[i][j])%MOD; } } ll ans=0; rep(i,7) ans=(ans+dp[k][i]*i%MOD)%MOD; cout<<ans<<endl; return 0; }