結果

問題 No.1448 和差算
ユーザー cpcznksutbeoacpcznksutbeoa
提出日時 2021-03-23 14:42:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 646 bytes
コンパイル時間 1,373 ms
コンパイル使用メモリ 164,180 KB
実行使用メモリ 814,796 KB
最終ジャッジ日時 2023-08-20 13:09:10
合計ジャッジ時間 3,906 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 MLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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_pow(16,N/8)%mod<<endl;
}
0