結果
| 問題 | No.673 カブトムシ |
| コンテスト | |
| ユーザー |
ts_
|
| 提出日時 | 2018-04-15 05:32:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 943 bytes |
| 記録 | |
| コンパイル時間 | 1,284 ms |
| コンパイル使用メモリ | 159,148 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 05:59:02 |
| 合計ジャッジ時間 | 1,882 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 13 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;
const int mod=1000000007;
ll modpow(ll x,ll n,ll mod){
ll res=1;
while(n>0){if(n&1ll) res=res*x%mod;x=x*x%mod;n>>=1;}
return res;
}
ll exgcd(ll a,ll b,ll& x,ll& y){
ll d=a;
if(b!=0){
d=exgcd(b,a%b,y,x);
y-=(a/b)*x;
}
else{
x=1;y=0;
}
return d;
}
ll mod_inverse(ll a,ll m){
ll x,y;
exgcd(a,m,x,y);
return (m+x%m)%m;
}
int main(){
ll b,c,d;
cin>>b>>c>>d;
if(d==1){
cout<<b%mod*c%mod<<endl;
return 0;
}
if(c==1){
b%=mod,d%=mod;
cout<<b*d%mod<<endl;
return 0;
}
b%=mod,c%=mod;
ll cn=modpow(c,d,mod);
ll ans=c*((1-cn)+mod)%mod*mod_inverse((1-c)+mod,mod)%mod*b%mod;
cout<<ans%mod<<endl;
return 0;
}
ts_