結果
問題 | No.1252 数字根D |
ユーザー |
|
提出日時 | 2020-10-09 23:42:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 347 bytes |
コンパイル時間 | 1,669 ms |
コンパイル使用メモリ | 165,584 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 14:33:44 |
合計ジャッジ時間 | 2,232 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 14 |
ソースコード
#include<bits/stdc++.h> using namespace std; long long t,d,a,b; long long f(long long x,long long y){ if(x<=0)return 0; long long rim=x%(y-1); return (x/(y-1))*((y*(y-1))/2)+(rim*(rim+1))/2; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cin>>t; while(t--){ cin>>d>>a>>b; cout<<f(b,d)-f(a-1,d)<<"\n"; } return 0; }