結果

問題 No.1803 Remainder of Sum
ユーザー ktr216ktr216
提出日時 2022-01-07 22:52:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 989 bytes
コンパイル時間 1,516 ms
コンパイル使用メモリ 164,476 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 18:52:01
合計ジャッジ時間 4,130 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

using ll = long long;
using VI = vector<int>;
using P = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++)
#define ALL(a) (a).begin(),(a).end()

constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;
constexpr int DX[] = {1, 0, -1, 0};
constexpr int DY[] = {0, 1, 0, -1};

template< typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true); }
template< typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true); }

int main() {
    int T;
    cin >> T;
    vector<ll> N(T), M(T);
    REP(i, T) cin >> N[i] >> M[i];
    REP(i, T) {
        if (M[i] == 1) {
            cout << 0 << endl;
            continue;;
        }
        if (M[i] < 4) {
            cout << 1 << endl;
            continue;
        }
        ll A = M[i] / 2;
        cout << A * (A + 1) / 2 + A - 2 << endl;
    }
}
0