結果
| 問題 | No.1252 数字根D | 
| コンテスト | |
| ユーザー |  srjywrdnprkt | 
| 提出日時 | 2023-12-23 17:52:36 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 6 ms / 2,000 ms | 
| コード長 | 456 bytes | 
| コンパイル時間 | 2,034 ms | 
| コンパイル使用メモリ | 193,192 KB | 
| 最終ジャッジ日時 | 2025-02-18 13:51:59 | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 14 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll f(ll x, ll d){
    if (x <= 0) return 0;
    ll q = x/(d-1), r = x % (d-1), s = d*(d-1)/2;
    return q*s + r*(r+1)/2;
}
void solve(){
    ll d, a, b;
    cin >> d >> a >> b;
    cout << f(b, d)-f(a-1, d) << endl;
}
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int T;
    cin >> T;
    while(T){
        T--;
        solve();
    }
    return 0;
}
            
            
            
        