結果
問題 | No.1448 和差算 |
ユーザー |
|
提出日時 | 2021-03-31 11:00:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 589 bytes |
コンパイル時間 | 4,419 ms |
コンパイル使用メモリ | 250,260 KB |
最終ジャッジ日時 | 2025-01-20 01:08:40 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> using namespace std; using namespace atcoder; const long mod=1000000007; 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; assert(A<=B); assert(C<=D); assert(abs(A)<=1e9); assert(abs(B)<=1e9); assert(abs(C)<=1e9); assert(abs(D)<=1e9); assert(0<=N); assert(N<=1e18); ans=max({f(A,C,N%8),f(A,D,N%8),f(B,C,N%8),f(B,D,N%8)})%mod*pow_mod(16,N/8,mod)%mod; if(ans<0){ cout<<ans+mod<<endl; } else{ cout<<ans<<endl; } }