結果
| 問題 |
No.1252 数字根D
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-09 21:33:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 312 bytes |
| コンパイル時間 | 542 ms |
| コンパイル使用メモリ | 64,304 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-20 09:00:50 |
| 合計ジャッジ時間 | 1,388 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 14 |
コンパイルメッセージ
main.cpp:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
13 | main()
| ^~~~
ソースコード
#include<iostream>
using namespace std;
int T;
long f(long d,long N)
{
if(N==0)return 0;
long ans=N;
ans+=N/(d-1)*((d-1)*(d-2)/2);
long t=N%(d-1);
ans+=t*(t-1)/2;
return ans;
}
main()
{
cin>>T;
for(;T--;)
{
int d,A,B;
cin>>d>>A>>B;
long ans=f(d,B);
if(A>0)ans-=f(d,A-1);
cout<<ans<<endl;
}
}