結果

問題 No.1899 L1 Cafe
ユーザー 👑 colognecologne
提出日時 2022-04-08 21:38:56
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 443 bytes
コンパイル時間 2,790 ms
コンパイル使用メモリ 247,340 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-19 00:18:46
合計ジャッジ時間 4,965 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 47 ms
4,376 KB
testcase_02 AC 45 ms
4,380 KB
testcase_03 AC 24 ms
4,376 KB
testcase_04 AC 31 ms
4,380 KB
testcase_05 AC 15 ms
4,380 KB
testcase_06 AC 52 ms
4,380 KB
testcase_07 AC 36 ms
4,380 KB
testcase_08 AC 38 ms
4,380 KB
testcase_09 AC 44 ms
4,376 KB
testcase_10 AC 45 ms
4,380 KB
testcase_11 AC 43 ms
4,376 KB
testcase_12 AC 45 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/math>
using namespace std;

int main()
{
    int T;
    scanf("%d", &T);
    while (T--)
    {
        long N, A, B;
        scanf("%ld%ld%ld", &N, &A, &B);
        long ans = 0;
        ans += N * (N / A) - A * (N / A) * (N / A + 1) / 2;
        ans += N * (N / B) - B * (N / B) * (N / B + 1) / 2;
        if(N >= A) ans -= atcoder::floor_sum(N / A, B, A, N%A);
        printf("%ld\n", ans);
    }
}
0