結果
| 問題 |
No.1448 和差算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-21 16:46:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 484 bytes |
| コンパイル時間 | 2,763 ms |
| コンパイル使用メモリ | 192,804 KB |
| 最終ジャッジ日時 | 2025-01-19 20:54:22 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 TLE * 1 |
| other | AC * 10 TLE * 26 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
const long mod=1000000007;
long modpow(long a,long b){
long res=1;
for(int i=0;i<b;i++){
res=res*a%mod;
}
return res;
}
long f(long a,long b,long N){
for(int i=0;i<N;i++){
a-=b;b+=a+b;
}
return a+b;
}
int main(){
long A,B,C,D,N,ans;
cin>>A>>B>>C>>D>>N;
ans=max({f(A,C,N%8),f(A,D,N%8),f(B,C,N%8),f(B,D,N%8)})%mod*modpow(16,N/8)%mod;
if(ans<0){
cout<<ans+mod<<endl;
}
else{
cout<<ans<<endl;
}
}