結果

問題 No.1448 和差算
ユーザー hibit_athibit_at
提出日時 2021-03-31 15:57:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,426 bytes
コンパイル時間 760 ms
コンパイル使用メモリ 83,476 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-08 19:18:55
合計ジャッジ時間 1,825 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 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 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 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 2 ms
5,376 KB
testcase_20 AC 2 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 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 WA -
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 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define all(A) A.begin(), A.end()
typedef long long ll;

ll mod = (ll)pow(10, 9) + 7;

double heron(pair<int, int> start, pair<int, int> target1,
             pair<int, int> target2) {
  target1.first -= start.first;
  target1.second -= start.second;
  target2.first -= start.first;
  target2.second -= start.second;
  return abs(target1.first * target2.second - target2.first * target1.second);
}

ll rpow(ll a, ll r, ll mod) {
  if (r == 0)
    return 1;
  ll ans = rpow(a, r / 2, mod);
  ans *= ans;
  ans %= mod;
  if (r % 2 == 1)
    ans *= a;
  ans %= mod;
  return ans;
}

int main() {
  ll a, b, c, d, n;
  cin >> a >> b >> c >> d >> n;
  ll scale = n / 8;
  n %= 8;
  ll base = 0;
  if (n == 0) {
    base = b + d;
  }
  if (n == 1) {
    base = 2 * b;
  }
  if (n == 2) {
    base = 2 * b - 2 * c;
  }
  if (n == 3) {
    base = -4 * c;
  }
  if (n == 4) {
    base = -4 * a - 4 * c;
  }
  if (n == 5) {
    base = -8 * a;
  }
  if (n == 6) {
    base = -8 * a + 8 * d;
  }
  if (n == 7) {
    base = 16 * d;
  }
  scale = rpow(16, scale, mod);
  ll ans = scale * base;
  ans %= mod;
  ans += mod;
  ans %= mod;
  cout << ans << endl;
}
0