結果

問題 No.1252 数字根D
ユーザー Mister
提出日時 2020-10-09 21:37:20
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 493 bytes
コンパイル時間 559 ms
コンパイル使用メモリ 72,468 KB
最終ジャッジ日時 2025-01-15 04:10:44
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>

using lint = long long;

lint calc(lint n, lint d) {
    --d;
    lint block = n / d;
    n -= block * d;
    return d * (d + 1) / 2 * block + n * (n + 1) / 2;
}

void solve() {
    lint d, a, b;
    std::cin >> d >> a >> b;
    std::cout << calc(b, d) - calc(a - 1, d) << "\n";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int q;
    std::cin >> q;
    while (q--) solve();

    return 0;
}
0