結果

問題 No.1448 和差算
ユーザー 👑 NachiaNachia
提出日時 2021-03-31 14:17:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 751 bytes
コンパイル時間 1,953 ms
コンパイル使用メモリ 200,708 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-08 14:13:39
合計ジャッジ時間 2,895 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

const ull M=1000000007;

ull powm(ull a,ull i){
  if(i==0) return 1;
  ull r=powm(a*a%M,i/2);
  if(i%2==1) r=r*a%M;
  return r;
}

ll A,B,C,D,N;

int main(){
  cin>>A>>B>>C>>D>>N;
  A=(A+M*100)%M;
  B=(B+M*100)%M;
  C=(C+M*100)%M;
  D=(D+M*100)%M;
  ull Mul = powm(16,N/8); N%=8;
  if(N%8>=4){
    Mul=Mul*4%M;
    swap(A,B); A=(M-A)%M; B=(M-B)%M;
    swap(C,D); C=(M-C)%M; D=(M-D)%M;
    N-=4;
  }
  if(N%4>=2){
    Mul=Mul*2%M;
    swap(A,C); swap(B,D);
    swap(A,B); A=(M-A)%M; B=(M-B)%M;
    N-=2;
  }
  if(N%2==1){
    cout<<(B*2*Mul%M)<<"\n";
  }
  else{
    cout<<((B+D)*Mul%M)<<"\n";
  }
  return 0;
}
0