結果

問題 No.1281 Cigarette Distribution
ユーザー 👑 NachiaNachia
提出日時 2020-11-06 22:11:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,852 bytes
コンパイル時間 1,762 ms
コンパイル使用メモリ 165,720 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-29 18:53:22
合計ジャッジ時間 4,945 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

template<ULL M>
struct static_modint {
    ULL x;
    static_modint(ULL val = 0) : x(val) {}

    static_modint& operator+=(static_modint r) { x += r.x; if (x >= M) x -= M; return *this; }
    static_modint operator+(static_modint r) const { static_modint res = x; return res += r; }
    static_modint& operator-=(static_modint r) { x += M - r.x; if (x >= M) x -= M; return *this; }
    static_modint operator-(static_modint r) const { static_modint res = x; return res -= r; }
    static_modint& operator*=(static_modint r) { x = x * r.x % M; return *this; }
    static_modint operator*(static_modint r) const { return static_modint(x * r.x % M); }
    static_modint pow(ULL r) const {
        if (r == 0) return static_modint(1);
        static_modint res = pow(r / 2);
        res *= res;
        if (r % 2) res *= *this;
        return res;
    }
    static_modint& operator/=(static_modint r) { *this *= r.pow(M - 1); return *this; }
    static_modint operator/(static_modint r) const { return *this * (r.pow(M - 2)); }
    ULL& operator*() { return x; }
    const ULL& operator*() const { return x; }
    bool operator==(static_modint r) const { return x == r; }
    bool operator!=(static_modint r) const { return x != r; }
};

const ULL M = 1000000007;
using MLL = static_modint<M>;

int N, K;

int main() {
    cin >> N >> K;

    for(int i = 1; i <= K; i++) {
        MLL ans;
        if (i != 1 && N % i == 0){
            ans = MLL(N / i).pow(i - 2);
            ans *= MLL(N / i + 1);
            ans *= MLL(N / i - 1);
        }
        else {
            ans = MLL(N / i + 1).pow(N % i);
            ans *= MLL(N / i).pow(i - N % i);
        }
        cout << *ans << endl;
    }

	return 0;
}

0