結果
| 問題 |
No.1252 数字根D
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-09 21:27:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 366 bytes |
| コンパイル時間 | 1,796 ms |
| コンパイル使用メモリ | 192,184 KB |
| 最終ジャッジ日時 | 2025-01-15 03:55:42 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 14 |
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:15:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | int d,a,b; scanf("%d%d%d",&d,&a,&b);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:20:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | int q; scanf("%d",&q); rep(_,q) solve();
| ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
lint f(lint x,lint d){
lint m=x/(d-1);
lint r=x%(d-1);
return d*(d-1)/2*m+r*(r+1)/2;
}
void solve(){
int d,a,b; scanf("%d%d%d",&d,&a,&b);
printf("%lld\n",f(b,d)-f(a==0?0:a-1,d));
}
int main(){
int q; scanf("%d",&q); rep(_,q) solve();
return 0;
}