QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#232565#959. Multiple?JWRuixiWA 1ms3536kbC++202.0kb2023-10-30 16:33:082023-10-30 16:33:10

Judging History

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

  • [2023-10-30 16:33:10]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3536kb
  • [2023-10-30 16:33:08]
  • 提交

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 = 1;
    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!

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3408kb

input:

4 1

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3536kb

input:

9 2

output:

0

result:

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