結果

問題 No.1252 数字根D
ユーザー cureskolcureskol
提出日時 2022-11-16 10:33:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 418 bytes
コンパイル時間 1,909 ms
コンパイル使用メモリ 200,896 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 09:12:11
合計ジャッジ時間 2,981 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 3 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
}
0