結果
問題 | No.1844 Divisors Sum Sum |
ユーザー | kai4096_don |
提出日時 | 2022-02-18 22:03:14 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 503 ms / 3,000 ms |
コード長 | 2,617 bytes |
コンパイル時間 | 3,919 ms |
コンパイル使用メモリ | 231,844 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-11 19:11:23 |
合計ジャッジ時間 | 12,550 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 470 ms
4,380 KB |
testcase_01 | AC | 496 ms
4,376 KB |
testcase_02 | AC | 501 ms
4,376 KB |
testcase_03 | AC | 503 ms
4,380 KB |
testcase_04 | AC | 503 ms
4,380 KB |
testcase_05 | AC | 502 ms
4,380 KB |
testcase_06 | AC | 501 ms
4,376 KB |
testcase_07 | AC | 499 ms
4,380 KB |
testcase_08 | AC | 494 ms
4,376 KB |
testcase_09 | AC | 496 ms
4,380 KB |
testcase_10 | AC | 455 ms
4,380 KB |
testcase_11 | AC | 98 ms
4,376 KB |
testcase_12 | AC | 348 ms
4,380 KB |
testcase_13 | AC | 50 ms
4,376 KB |
testcase_14 | AC | 164 ms
4,380 KB |
testcase_15 | AC | 2 ms
4,376 KB |
testcase_16 | AC | 1 ms
4,380 KB |
testcase_17 | AC | 2 ms
4,380 KB |
testcase_18 | AC | 2 ms
4,376 KB |
testcase_19 | AC | 1 ms
4,380 KB |
testcase_20 | AC | 1 ms
4,376 KB |
testcase_21 | AC | 2 ms
4,380 KB |
testcase_22 | AC | 1 ms
4,380 KB |
testcase_23 | AC | 1 ms
4,376 KB |
testcase_24 | AC | 2 ms
4,380 KB |
testcase_25 | AC | 2 ms
4,380 KB |
testcase_26 | AC | 1 ms
4,380 KB |
testcase_27 | AC | 2 ms
4,384 KB |
testcase_28 | AC | 1 ms
4,380 KB |
testcase_29 | AC | 2 ms
4,380 KB |
testcase_30 | AC | 1 ms
4,376 KB |
testcase_31 | AC | 2 ms
4,380 KB |
testcase_32 | AC | 2 ms
4,380 KB |
testcase_33 | AC | 1 ms
4,380 KB |
testcase_34 | AC | 1 ms
4,380 KB |
testcase_35 | AC | 1 ms
4,380 KB |
testcase_36 | AC | 1 ms
4,376 KB |
testcase_37 | AC | 2 ms
4,376 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; const long nPrime = 1000000007; //const long nPrime = 998244353; typedef long long ll; const long long nMod = nPrime; class ModInt { long long x; public: ModInt(long long x=0) : x((x%nMod+nMod)%nMod) {} ModInt operator-() const { return ModInt(-x); } ModInt& operator+=(const ModInt& a) { if ((x += a.x) >= nMod) x -= nMod; return *this; } ModInt& operator-=(const ModInt& a) { if ((x += nMod-a.x) >= nMod) x -= nMod; return *this; } ModInt& operator*=(const ModInt& a) { (x *= a.x) %= nMod; return *this; } ModInt operator+(const ModInt& a) const { ModInt res(*this); return res+=a; } ModInt operator-(const ModInt& a) const { ModInt res(*this); return res-=a; } ModInt operator*(const ModInt& a) const { ModInt res(*this); return res*=a; } ModInt Pow(long long t) const { if (!t) return 1; ModInt a = Pow(t>>1); a *= a; if (t&1) a *= *this; return a; } // for prime nMod ModInt Inv() const { return Pow(nMod-2); } ModInt& operator/=(const ModInt& a) { return (*this) *= a.Inv(); } ModInt operator/(const ModInt& a) const { ModInt res(*this); return res/=a; } friend ostream& operator<<(ostream& os, const ModInt& m){ os << m.x; return os; } }; void MakeTable(vector<ModInt> &viInv, vector<ModInt> &viFctr, vector<ModInt> &viFctrInv, bool bUseFctr = false, const long nTableSize = 1000000){ viInv.resize(nTableSize+1, 1); for(long i = 1; i < nTableSize+1; i++){ viInv[i] /= i; } if(!bUseFctr){ return; } viFctr.resize(nTableSize+1, 1); viFctrInv.resize(nTableSize+1, 1); for(long i = 1; i < nTableSize+1; i++){ viFctr[i] = viFctr[i-1] * i; } viFctrInv[nTableSize] /= viFctr[nTableSize]; for(long i = nTableSize; i >= 1; i--){ viFctrInv[i-1] = viFctrInv[i]*i; } } int main() { long n; cin >> n; ModInt nAns = 1; for(long i = 0; i < n; i++){ long p,e; cin >> p >> e; ModInt pm = p,em = e; ModInt S1 = (em+1); S1 *= ((pm.Pow(e+1)-1)/(pm-1)); ModInt S2 = 1; S2 /= (ModInt(1)-pm); S2 *= ((pm.Pow(e+1)-p)/(pm-1) - em*pm.Pow(e+1)); nAns *= (S1-S2); } cout << nAns <<endl; return 0; }