結果
問題 | No.1448 和差算 |
ユーザー |
![]() |
提出日時 | 2021-03-31 14:17:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 613 bytes |
コンパイル時間 | 4,207 ms |
コンパイル使用メモリ | 250,020 KB |
最終ジャッジ日時 | 2025-01-20 01:25:29 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
#include <stdio.h>#include <bits/stdc++.h>#include <atcoder/all>using namespace atcoder;using mint = modint1000000007;using namespace std;#define rep(i,n) for (int i = 0; i < (n); ++i)#define Inf 1000000000000000001int main(){long long A,B,C,D;cin>>A>>B>>C>>D;long long N;cin>>N;N++;mint ans;if(N%8>=4){swap(A,B);swap(C,D);}switch(N%4){case 0:{ans = D;break;}case 1:{ans = B+D;break;}case 2:{ans = B*2;break;}case 3:{ans = -C*2+B*2;break;}}ans *= mint(-4).pow(N/4);cout<<ans.val()<<endl;return 0;}