結果

問題 No.1448 和差算
ユーザー ytqm3ytqm3
提出日時 2021-03-23 15:03:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 652 bytes
コンパイル時間 2,319 ms
コンパイル使用メモリ 197,372 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 13:10:47
合計ジャッジ時間 3,107 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
ll mod_pow(ll a,ll 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_pow(16,N/8)%mod<<endl;
}
0