QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#360703 | #959. Multiple? | tvladm | WA | 2ms | 3656kb | C++17 | 2.2kb | 2024-03-22 01:03:13 | 2024-03-22 01:03:14 |
Judging History
answer
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
using ll = long long;
using ld = long double;
const string FILENAME = "input";
const int Mod = 998244353;
int phi(int n) {
ll sol = n;
int d = 2;
while (d * d <= n) {
int e = 0;
while (n % d == 0) {
n /= d;
e++;
}
if (e > 0) {
sol *= d - 1;
sol /= d;
}
d++;
}
if (n > 1) {
sol *= n - 1;
sol /= n;
}
return sol;
}
int mul(int a, int b) {
return 1LL * a * b % Mod;
}
int powm(int a, int b) {
int res = 1;
while (b > 0) {
if (b & 1) {
res = mul(res, a);
}
a = mul(a, a);
b >>= 1;
}
return res;
}
int dv(int a, int b) {
return mul(a, powm(b, Mod - 2));
}
int comb(int n, int k) {
int res = 1;
for (int i = 1; i <= k - 1; i++) {
res = mul(res, i);
res = mul(res, n - i);
}
return res;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
//read(FILENAME);
int n, k;
cin >> n >> k;
cout << mul(phi(n), comb(n, k)) << '\n';
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3604kb
input:
4 1
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
9 2
output:
48
result:
ok 1 number(s): "48"
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 3656kb
input:
222222222 222222
output:
635685411
result:
wrong answer 1st numbers differ - expected: '851798824', found: '635685411'