結果
問題 | No.1252 数字根D |
ユーザー |
![]() |
提出日時 | 2020-10-09 22:23:20 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 409 bytes |
コンパイル時間 | 754 ms |
コンパイル使用メモリ | 28,416 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-20 12:27:06 |
合計ジャッジ時間 | 1,644 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 14 |
ソースコード
#include<stdio.h> long long int f(long long int n, long long int d) { if (n == 0) return 0; long long int res = n / (d - 1) * ((d - 1) * d / 2); n %= d - 1; res += n * (n + 1) / 2; return res; } int main() { int t; scanf("%d", &t); long long int d, a, b; for (; t > 0; t--) { scanf("%lld %lld %lld", &d, &a, &b); a--; if (a < 0) a++; printf("%lld\n", f(b, d) - f(a, d)); } return 0; }