結果
問題 | No.1252 数字根D |
ユーザー | cureskol |
提出日時 | 2022-11-16 10:33:36 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 418 bytes |
コンパイル時間 | 2,076 ms |
コンパイル使用メモリ | 200,520 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-17 07:38:44 |
合計ジャッジ時間 | 2,779 ms |
ジャッジサーバーID (参考情報) |
judge1 / 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'; }