結果
問題 | No.1844 Divisors Sum Sum |
ユーザー |
|
提出日時 | 2023-07-15 15:17:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 290 ms / 3,000 ms |
コード長 | 1,049 bytes |
コンパイル時間 | 898 ms |
コンパイル使用メモリ | 101,196 KB |
最終ジャッジ日時 | 2025-02-15 15:03:38 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 38 |
ソースコード
#include<iostream> #include<set> #include<algorithm> #include<vector> #include<string> #include<set> #include<map> #include<numeric> #include<queue> #include<cmath> using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair<int,int> P; typedef pair<int,P> PP; const ll MOD=1e9+7; const double PI=acos(-1); ll mod_pow(ll x,ll y,ll mod){ ll res=1; while(y>0){ if(y&1){ res*=x; res%=mod; } x*=x; x%=mod; y/=2; } return res; } int main(){ int L; cin>>L; vector<pair<ll,ll>> pe(L); for(int i=0;i<L;i++){ cin>>pe[i].first>>pe[i].second; } ll ans=1; for(auto [p,e]:pe){ ll invP=mod_pow((p-1+MOD)%MOD,MOD-2,MOD);//p-1の逆元 ll c=(mod_pow(p,e+1,MOD)-1+MOD)%MOD; c*=p%MOD; c%=MOD; c*=invP; c%=MOD; c-=(e+1)%MOD; c+=MOD; c%=MOD; c*=invP; c%=MOD; ans*=c; ans%=MOD; } cout<<ans<<endl; }