QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#232564#959. Multiple?JWRuixiWA 0ms3352kbC++202.0kb2023-10-30 16:32:472023-10-30 16:32:47

Judging History

你现在查看的是最新测评结果

  • [2023-10-30 16:32:47]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3352kb
  • [2023-10-30 16:32:47]
  • 提交

answer

#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx,avx2")
// #define ATC
#define LL long long
#define eb emplace_back
#define writesp(x) write(x), putchar(' ')
#define writeln(x) write(x), putchar('\n')
#define FIO(FILENAME) freopen(FILENAME".in", "r", stdin), freopen(FILENAME".out", "w", stdout)
using namespace std;

#ifdef ATC
#include <atcoder/all>
using namespace atcoder;
#endif

namespace IO {
    char ibuf[(1 << 20) + 1], *iS, *iT;
#if ONLINE_JUDGE
#define gh() (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, (1 << 20) + 1, stdin), (iS == iT ? EOF : *iS++) : *iS++)
#else
#define gh() getchar()
#endif
    inline long long read() {
        char ch = gh();
        long long x = 0;
        bool t = 0;
        while (ch < '0' || ch > '9') t |= ch == '-', ch = gh();
        while (ch >= '0' && ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = gh();
        return t ? ~(x - 1) : x;
    }
    template<typename _Tp>
    inline void write(_Tp x) {
        static char stk[64], *top = stk;
        if (x < 0) {
            x = ~(x - 1);
            putchar('-');
        }
        do *top++ = x % 10, x /= 10;
        while (x);
        while (top != stk) putchar((*--top) | 48);
    }
}

using IO::read;
using IO::write;

constexpr int mod = 998244353;
int n, k;

inline int ksm(int b, int k) {
    int r = 1;
    for (; k; k >>= 1, b = (LL)b * b % mod) if (k & 1) r = (LL)r * b % mod;
    return r;
}

inline int Binom (int n, int m) {
    int r = 1;
    for (int i = 1; i <= m; i++) r = (LL)r * i % mod;
    r = ksm(r, mod - 2);
    for (int i = 0; i < m; i++) r = (LL)r * (n - i) % mod;
    return r;
}

int main() {
    n = read(), k = read();
    int r = 0;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            r *= (i - 1);
            n /= i;
            while (n % i == 0) r *= i, n /= i;
        }
    }
    if (n > 1) {
        r *= (n - 1);
    }
	 r = (LL)r * Binom(n - 1, k - 1) % mod;
    write(r);
}
// I love WHQ!

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3352kb

input:

4 1

output:

0

result:

wrong answer 1st numbers differ - expected: '2', found: '0'