結果

問題 No.1448 和差算
ユーザー ytqm3
提出日時 2021-03-21 16:42:32
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 398 bytes
コンパイル時間 3,951 ms
コンパイル使用メモリ 249,920 KB
最終ジャッジ日時 2025-01-19 20:52:52
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1
other WA * 16 TLE * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
  ans=max({f(A,C,N),f(A,D,N),f(B,C,N),f(B,D,N)})%mod;
  if(ans<0){
    cout<<ans+mod<<endl;
  }
  else{
    cout<<ans<<endl;
  }
}
0