結果

問題 No.2233 Average
ユーザー Yudai0606NazoYudai0606Nazo
提出日時 2023-03-09 19:35:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 555 ms / 2,000 ms
コード長 928 bytes
コンパイル時間 4,651 ms
コンパイル使用メモリ 237,788 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 06:24:50
合計ジャッジ時間 9,656 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 322 ms
4,348 KB
testcase_09 AC 487 ms
4,348 KB
testcase_10 AC 411 ms
4,348 KB
testcase_11 AC 401 ms
4,348 KB
testcase_12 AC 350 ms
4,348 KB
testcase_13 AC 80 ms
4,348 KB
testcase_14 AC 269 ms
4,348 KB
testcase_15 AC 369 ms
4,348 KB
testcase_16 AC 103 ms
4,348 KB
testcase_17 AC 133 ms
4,348 KB
testcase_18 AC 555 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repf(i, n, flag) for (int i = 0; i < (int)(n) && flag; i++)
#define all(v) v.begin(), v.end()


using T = tuple<ll, ll, ll>;
ll solve() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    vector<ll> his;
    map<T, ll> his_m;
    int f, r;
    for(int i = 0;; i++) {
        his_m[{a, b, c}] = i;
        his.push_back(a+b+c);
        ll na = (b+c) / 2;
        ll nb = (c+a) / 2;
        ll nc = (a+b) / 2;
        a = na, b = nb, c = nc;
        if(his_m.count({a, b, c})) {
            f = his_m[{a, b, c}];
            r = i - f + 1;
            break;
        }
    }
    
    if(k < f) return his[k];
    return his[(k-f)%r + f];
}

int main() {
    int t;
    cin >> t;
    while(t--) cout << solve() << endl;
}
0