結果

問題 No.1097 Remainder Operation
コンテスト
ユーザー tricky_epithet
提出日時 2026-10-06 22:33:53
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 994 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,391 ms
コンパイル使用メモリ 340,832 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2026-10-06 22:34:02
合計ジャッジ時間 7,245 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 2 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl '\n'

/*

n = 7

a0 = 9
*/

int main() {
    // ll t; cin >> t;

    // while (t--) {
        ll n; cin >> n;
        
        vector<ll> v(n);
        
        for (int i = 0; i < n; ++i) cin >> v[i];
        ll q; cin >> q;
        
        ll thresh = 0;
        vector<ll> precomp(n + 1, 0);

        map<ll, ll> freq;

        ll x = 0;

        ll sum = 0;

        while (true) {
            ll idx = x % n;
            freq[idx]++;

            if (freq[idx] > 1) break;

            ++thresh;

            x += v[idx];
            sum += v[idx];

            precomp[thresh] = x;
        }

        while (q--) {
            ll k; cin >> k;

            ll ans = 0;
            // cout << precomp[k % thresh] << endl;
            ll mult = k / thresh;
            ans += mult * sum;

            ll off = k % thresh;
            ans += precomp[off];

            cout << ans << endl;
        }
    // }
}
0