結果

問題 No.1899 L1 Cafe
ユーザー 37zigen37zigen
提出日時 2022-01-31 06:15:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 995 bytes
コンパイル時間 734 ms
コンパイル使用メモリ 68,448 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2023-10-14 04:31:46
合計ジャッジ時間 4,375 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,704 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    int T;
    cin >> T;
    while (T-->0) {
        int N, A, B;
        cin >> N >> A >> B;
        long long ans=0;
        {
            int top=N-A;
            int bottom=A-(A-N%A)%A;
            ans+=(long long)((top-bottom)/A+1)*(top+bottom)/2;
        }
        {
            int top=N-B;
            int bottom=B-(B-N%B)%B;
            ans+=(long long)((top-bottom)/B+1)*(top+bottom)/2;
        }
        int i=1;
        while (i<=N/A) {
            int k=(N-A*i)/B;
            int ni=(N-B*k)/A+1;
            ans-=(long long)k*(ni-i);
            i=ni;
        }
        cout << ans << endl;
    }
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/
0