結果
問題 |
No.1252 数字根D
|
ユーザー |
![]() |
提出日時 | 2020-10-09 23:49:31 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 562 bytes |
コンパイル時間 | 1,709 ms |
コンパイル使用メモリ | 193,000 KB |
最終ジャッジ日時 | 2025-01-15 05:57:18 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 11 WA * 3 |
ソースコード
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include <bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--){ ll d,a,b; cin>>d>>a>>b; ll ans=0; ll x=(b-a)/(d-1); ans+=(d-1)*d/2*x; ll p,q; if((a+x*(d-1))%(d-1)==0) p=d-1; else p=(a+x*(d-1))%(d-1); if(b%(d-1)==0) q=d-1; else q=b%(d-1); if(p<q) ans+=(q-p+1)*(p+q)/2; else ans+=(d-p)*(p+d-1)/2+q*(q+1)/2; cout<<ans<<endl; } return 0; }