結果
| 問題 |
No.1448 和差算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-23 14:51:44 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 660 bytes |
| コンパイル時間 | 9,209 ms |
| コンパイル使用メモリ | 252,140 KB |
| 最終ジャッジ日時 | 2025-01-19 21:14:47 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 10 WA * 13 TLE * 1 MLE * 12 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
ll mod_pow(ll a,int b){
if(!b)return 1;
if(b&1)return mod_pow(a,b-1)*a%mod;
ll c=mod_pow(a,b>>1);
return c*c%mod;
}
int main(){
ll A,B,C,D,N; cin>>A>>B>>C>>D>>N;
ll ans=0;
if(N%8==0)ans=B+D; //a ,b
if(N%8==1)ans=2*B; //a-b ,a+b
if(N%8==2)ans=2*B-2*C; //-2b ,2a
if(N%8==3)ans=-4*C; //-2a-2b,2a-2b
if(N%8==4)ans=-4*A-4*C; //-4a ,-4b
if(N%8==5)ans=-8*A; //-4a+4b,-4a-4b
if(N%8==6)ans=-8*A+8*D; //8b ,-8a
if(N%8==7)ans=16*D; //8a+8b ,-8a+8b
cout<<(ans%mod+mod)%mod*mod_pow(16,N/8)%mod<<endl;
}