結果

問題 No.1899 L1 Cafe
ユーザー 👑 colognecologne
提出日時 2022-04-08 21:38:56
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 443 bytes
コンパイル時間 2,703 ms
コンパイル使用メモリ 247,476 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-06 07:11:42
合計ジャッジ時間 5,329 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 49 ms
5,248 KB
testcase_02 AC 46 ms
5,376 KB
testcase_03 AC 24 ms
5,376 KB
testcase_04 AC 31 ms
5,376 KB
testcase_05 AC 16 ms
5,376 KB
testcase_06 AC 54 ms
5,376 KB
testcase_07 AC 35 ms
5,376 KB
testcase_08 AC 39 ms
5,376 KB
testcase_09 AC 42 ms
5,376 KB
testcase_10 AC 47 ms
5,376 KB
testcase_11 AC 43 ms
5,376 KB
testcase_12 AC 47 ms
5,376 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