結果
| 問題 |
No.1252 数字根D
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-02 15:47:48 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 998 bytes |
| コンパイル時間 | 1,829 ms |
| コンパイル使用メモリ | 193,636 KB |
| 最終ジャッジ日時 | 2025-02-17 04:01:04 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 12 WA * 2 |
ソースコード
#include<bits/stdc++.h>
#include<time.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vvvvll = vector<vvvll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vvvvb = vector<vvvb>;
bool DEB = 0;
ll arithsum(ll a,ll b,ll d=1){
ll len=(b-a+1);
return (a+b)*len/2;
}
void solve(){
ll D,A,B;
cin>>D>>A>>B;
if(A==0&&B==0){
cout<<0<<endl;
return;
}
A=max(1ll,A);
ll res=0;
ll len=(B-A+1);
res=(len/(D-1))*arithsum(1,D-1);
B-=(len/(D-1))*(D-1);
//cout<<A<<" "<<B<<endl;
A%=(D-1);
if(A==0)A+=(D-1);
B%=(D-1);
if(B==0)B+=(D-1);
if(A<=B){
res+=arithsum(A,B);
}
else{
res+=arithsum(A,D-1)+arithsum(1,B);
}
cout<<res<<endl;
return;
}
int main() {
ll T;
cin>>T;
rep(t,T)solve();
}