結果
| 問題 | No.1252 数字根D | 
| コンテスト | |
| ユーザー |  cureskol | 
| 提出日時 | 2022-11-16 10:33:36 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 418 bytes | 
| コンパイル時間 | 2,015 ms | 
| コンパイル使用メモリ | 192,644 KB | 
| 最終ジャッジ日時 | 2025-02-08 20:39:46 | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 14 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
using ll=long long;
ll f(int d,int n){
  if(n<=0)return 0;
  ll a=n/(d-1);
  ll b=n%(d-1);
  return a*(d-1)*d/2 + b*(b+1)/2;
}
ll solve(){
  int d,a,b;cin>>d>>a>>b;
  return f(d,b)-f(d,a-1);
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int testsize;cin>>testsize;
  while(testsize--)cout<<solve()<<'\n';
}
            
            
            
        