QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#232564 | #959. Multiple? | JWRuixi | WA | 0ms | 3352kb | C++20 | 2.0kb | 2023-10-30 16:32:47 | 2023-10-30 16:32:47 |
Judging History
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!
詳細信息
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'