結果

問題 No.2649 [Cherry 6th Tune C] Anthem Flower
ユーザー sho_sho_
提出日時 2024-03-06 23:19:56
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 594 ms / 2,000 ms
コード長 5,100 bytes
コンパイル時間 9,637 ms
コンパイル使用メモリ 510,256 KB
実行使用メモリ 12,276 KB
最終ジャッジ日時 2024-03-06 23:20:22
合計ジャッジ時間 19,897 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
11,300 KB
testcase_01 AC 493 ms
11,300 KB
testcase_02 AC 492 ms
11,300 KB
testcase_03 AC 523 ms
11,300 KB
testcase_04 AC 489 ms
11,300 KB
testcase_05 AC 594 ms
11,300 KB
testcase_06 AC 566 ms
11,300 KB
testcase_07 AC 34 ms
11,300 KB
testcase_08 AC 35 ms
11,300 KB
testcase_09 AC 13 ms
11,300 KB
testcase_10 AC 12 ms
11,300 KB
testcase_11 AC 7 ms
11,300 KB
testcase_12 AC 7 ms
11,300 KB
testcase_13 AC 112 ms
11,924 KB
testcase_14 AC 97 ms
11,800 KB
testcase_15 AC 78 ms
11,684 KB
testcase_16 AC 92 ms
11,684 KB
testcase_17 AC 154 ms
11,940 KB
testcase_18 AC 84 ms
11,684 KB
testcase_19 AC 113 ms
11,812 KB
testcase_20 AC 236 ms
12,016 KB
testcase_21 AC 118 ms
12,036 KB
testcase_22 AC 121 ms
11,924 KB
testcase_23 AC 267 ms
12,148 KB
testcase_24 AC 243 ms
12,148 KB
testcase_25 AC 243 ms
12,148 KB
testcase_26 AC 243 ms
12,148 KB
testcase_27 AC 242 ms
12,148 KB
testcase_28 AC 243 ms
12,148 KB
testcase_29 AC 242 ms
12,148 KB
testcase_30 AC 242 ms
12,276 KB
testcase_31 AC 245 ms
12,276 KB
testcase_32 AC 250 ms
12,148 KB
testcase_33 AC 241 ms
12,148 KB
testcase_34 AC 477 ms
11,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using ql = queue<ll>;
using sl = set<ll>;
using vl = vector<ll>;
using msl = multiset<ll>;
using Graph = vector<vector<ll>>;
using P = pair<ll, ll>;
template <typename T> inline bool chmax(T &a, T b) {
    return ((a < b) ? (a = b, true) : (false));
}
template <typename T> inline bool chmin(T &a, T b) {
    return ((a > b) ? (a = b, true) : (false));
}
#define YES                                                                    \
    {                                                                          \
        cout << "Yes\n";                                                       \
        return;                                                                \
    }
#define NO                                                                     \
    {                                                                          \
        cout << "No\n";                                                        \
        return;                                                                \
    }
#define rep1(i, n) for(ll i = 1; i <= ((ll)n); ++i)
#define rep(i, n) for(ll i = 0; i < ((ll)n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define INF ((1LL << 62) - (1LL << 31))
ll LCS(string s, string t) {
    ll n = s.size(), m = t.size();
    Graph dp(n, vl(m, 0));
    rep(i, n) {
        rep(j, m) {
            if(i)
                dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            if(j)
                dp[i][j] = max(dp[i][j], dp[i][j - 1]);
            if(s[i] == t[j]) {
                if(i && j)
                    dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
                else
                    dp[i][j] = 1;
            }
        }
    }
    rep(i, n) {
        // rep(j,m)cout<<dp[i][j]<<" ";
        // cout<<endl;
    }
    return dp[n - 1][m - 1];
}
template <class Type> size_t LIS(const std::vector<Type> &v) {
    std::vector<Type> dp;

    for(const auto &elem : v) {
        auto it = std::lower_bound(dp.begin(), dp.end(), elem);

        if(it == dp.end()) {
            dp.push_back(elem);
        } else {
            *it = elem;
        }
    }
    return dp.size();
}
template <bool Strict, class Type> size_t LIS(const std::vector<Type> &v) {
    std::vector<Type> dp;

    auto it = dp.begin();

    for(const auto &elem : v) {
        if constexpr(Strict) {
            it = std::lower_bound(dp.begin(), dp.end(), elem);
        } else {
            it = std::upper_bound(dp.begin(), dp.end(), elem);
        }

        if(it == dp.end()) {
            dp.push_back(elem);
        } else {
            *it = elem;
        }
    }

    return dp.size();
}

vector<pair<long long, long long>> prime_factorize(long long N) {
    // 答えを表す可変長配列
    vector<pair<long long, long long>> res;

    // √N まで試し割っていく
    for(long long p = 2; p * p <= N; ++p) {
        // N が p で割り切れないならばスキップ
        if(N % p != 0) {
            continue;
        }

        // N の素因数 p に対する指数を求める
        int e = 0;
        while(N % p == 0) {
            // 指数を 1 増やす
            ++e;

            // N を p で割る
            N /= p;
        }

        // 答えに追加
        res.emplace_back(p, e);
    }

    // 素数が最後に残ることがありうる
    if(N != 1) {
        res.emplace_back(N, 1);
    }
    return res;
}
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for(long long i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
template <typename T> void print(T &d) {
    for(auto &i : d)
        cout << i << " ";
    if(d.size())
        cout << endl;
}
vector<ll> dx = {1, 0, -1, 0};
vector<ll> dy = {0, 1, 0, -1};
using mint = modint998244353;
// using mint = modint1000000007;
// using mint = modint;
const ll MAX = 1000000;
vector<mint> fac(MAX + 1, 1);
vector<mint> ifac(MAX + 1, 1);
mint binomial(ll n, ll k) {
    if(k < 0 || n < k)
        return 0;
    if(n >= MAX) {
        mint num = 1, den = 1;
        k = min(k, n - k);
        rep(i, k) {
            num *= (n - i);
            den *= (i + 1);
        }
        return num / den;
    }
    return fac[n] * ifac[n - k] * ifac[k];
}
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
void solve() {
    cpp_int n, m;
    cin >> n >> m;
    cpp_int a = n, b = n + 1;
    if(n & 1)
        swap(a, b);
    a /= 2;
    cout << (a % m * b % m) % m << endl;
}

int main() {
    // test();
    cout << fixed << setprecision(20);
    // {   //前処理 MAX=1e6
    //     rep1(i,MAX)fac[i]=i*fac[i-1];
    //     ifac[MAX]=fac[MAX].inv();
    //     for(ll i=MAX;i>=1;i--)ifac[i-1]=ifac[i]*(i);
    // }
    ll t;
    // t = 1;
    cin >> t;
    rep(_, t) solve();
}
0