結果

問題 No.2017 Mod7 Parade
ユーザー umezoumezo
提出日時 2022-07-22 23:04:22
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 665 bytes
コンパイル時間 1,948 ms
コンパイル使用メモリ 199,864 KB
実行使用メモリ 10,256 KB
最終ジャッジ日時 2023-09-17 11:49:13
合計ジャッジ時間 3,773 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 26 ms
8,524 KB
testcase_04 AC 18 ms
6,860 KB
testcase_05 AC 14 ms
5,764 KB
testcase_06 AC 28 ms
9,136 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 18 ms
6,580 KB
testcase_09 AC 8 ms
4,404 KB
testcase_10 AC 17 ms
6,504 KB
testcase_11 AC 24 ms
7,904 KB
testcase_12 AC 21 ms
7,320 KB
testcase_13 AC 33 ms
10,204 KB
testcase_14 AC 33 ms
10,152 KB
testcase_15 AC 33 ms
10,200 KB
testcase_16 AC 33 ms
10,256 KB
testcase_17 AC 33 ms
10,156 KB
testcase_18 AC 33 ms
10,252 KB
testcase_19 AC 27 ms
10,232 KB
testcase_20 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0