結果
問題 | No.2703 FizzBuzz Letter Counting |
ユーザー | Magentor |
提出日時 | 2024-03-15 01:14:18 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,513 bytes |
コンパイル時間 | 5,853 ms |
コンパイル使用メモリ | 317,312 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-09-30 15:18:51 |
合計ジャッジ時間 | 8,757 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
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 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
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 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | AC | 2 ms
5,248 KB |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | AC | 1 ms
5,248 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); } template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); } #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define rep2(i, m ,n) for (int i = (m); i < (long long)(n); i++) #define REP(i, n) for (long long i = 1; i < (long long)(n); i++) typedef long long ll; #define updiv(N,X) (N + X - 1) / X #define l(n) n.begin(),n.end() #define YesNo(Q) Q==1?cout<<"Yes":cout<<"No" using P = pair<int, int>; using mint = modint; const int MOD = 998244353LL; const ll INF = 999999999999LL; vector<long long> fact, fact_inv, inv; /* init_nCk :二項係数のための前処理 計算量:O(n) */ template <typename T> void input(vector<T> &v){ rep(i,v.size()){cin>>v[i];} return; } void init_nCk(int SIZE) { fact.resize(SIZE + 5); fact_inv.resize(SIZE + 5); inv.resize(SIZE + 5); fact[0] = fact[1] = 1; fact_inv[0] = fact_inv[1] = 1; inv[1] = 1; for (int i = 2; i < SIZE + 5; i++) { fact[i] = fact[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD; } } /* nCk :MODでの二項係数を求める(前処理 int_nCk が必要) 計算量:O(1) */ long long nCk(int n, int k) { assert(!(n < k)); assert(!(n < 0 || k < 0)); return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD; } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } ll POW(ll a,ll n){ long long res = 1; while (n > 0) { if (n & 1) res = res * a; a = a * a; n >>= 1; } return res; } vector<vector<ll>> mat_mul(vector<vector<ll>> a, vector<vector<ll>> b, ll mod) { // 行列乗算 int n = a.size(); vector<vector<ll>> res(n, vector<ll>(n)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { for (int k = 0; k < n; k++) { res[i][j] += a[i][k] * b[k][j]; res[i][j] %= mod; } } } return res; } vector<vector<ll>> mat_pow(vector<vector<ll>> a, ll b, ll mod) { // 行列累乗 int n = a.size(); vector<vector<ll>> res(n, vector<ll>(n)); for (int i = 0; i < n; i++) res[i][i] = 1; while (b) { if (b & 1) res = mat_mul(res, a, mod); a = mat_mul(a, a, mod); b >>= 1; } return res; } ll rp(ll a,ll m){ vector<vector<ll>> f = { {10,1},{0,1} }; vector<vector<ll>> g = mat_pow(f, a, m); return g[0][1]; } inline long long mod(long long a, long long m) { return (a % m + m) % m; } long long extGcd(long long a, long long b, long long &p, long long &q) { if (b == 0) { p = 1; q = 0; return a; } long long d = extGcd(b, a%b, q, p); q -= a/b * p; return d; } pair<long long, long long> ChineseRem(long long b1, long long m1, long long b2, long long m2) { long long p, q; long long d = extGcd(m1, m2, p, q); if ((b2 - b1) % d != 0) return make_pair(0, -1); long long m = m1 * (m2/d); long long tmp = (b2 - b1) / d * p % (m2/d); long long r = mod(b1 + m1 * tmp, m); return make_pair(r, m); } int main() { int n;cin>>n; vector<ll> v(n);vector<ll> w(n); ll sm = 0; rep(i,n){cin>>v[i]>>w[i];sm += w[i];} if(1==sm){cout<<w[0]+(w[0]/3+w[0]/5)*3<<endl;return 0;} mint ans = 0; ans += modpow(10LL,sm-1,998244353LL); ans *= (9*(sm-1)+35); ans -= 440; ans *= 8;ans /= 135; ans += 21; // cout << ans.val() << endl; ll md15 = 0; ll md998 = 0; ll sm2 = sm; rep(i,n){ sm2 -= w[i]; // md15 += (modpow(10LL,sm2,15LL)*rp(w[i],15)*v[i]);md15 %= 15; // md998 += (modpow(10LL,sm2,998244353LL)*rp(w[i],998244353LL)*v[i]);md998 %= 998244353LL; } md15 += 1-modpow(10LL,sm-1,15LL); //cout << 1-modpow(10LL,sm,15LL) << endl; md15 = (md15%15+15)%15; md998 += 1-modpow(10LL,sm-1,998244353LL); //cout << md998 << endl; md998 = (md998%998244353LL+998244353LL)%998244353LL; // cout << sm << endl; rep(i,md15){ if((i+modpow(10LL,sm-1,15LL))%3==0){ans += 4-sm;} if((i+modpow(10LL,sm-1,15LL))%5==0){ans += 4-sm;} if((i+modpow(10LL,sm-1,15LL))%15==0){ans += sm;} ans += sm; } //cout << ans.val() << endl; // cout << md998 << endl; ll t = ChineseRem(md15,15LL,md998,998244353LL).first; ans += ((8*sm+32)%998244353LL)*(t/15); cout << ans.val() << endl; //cout << rp(3,10000) << endl; }