結果

問題 No.1899 L1 Cafe
ユーザー 👑 NachiaNachia
提出日時 2022-04-08 21:50:05
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 693 bytes
コンパイル時間 720 ms
コンパイル使用メモリ 81,564 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-19 00:28:09
合計ジャッジ時間 2,624 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <atcoder/math>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)

i64 solve(i64 n, i64 a, i64 b){
    return atcoder::floor_sum(n/b, a, b, n%b);
}

int main(){
    int T; cin >> T;
    while(T --> 0){
        i64 n,a,b; cin >> n >> a >> b;
        i64 ans = solve(n,a,1) + solve(n,1,b) - solve(n,a,b);
        cout << ans << '\n';
    }
    return 0;
}

struct ios_do_not_sync{
    ios_do_not_sync(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
    }
} ios_do_not_sync_instance;
0