QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#424007 | #959. Multiple? | fangzichang | TL | 26ms | 3624kb | C++20 | 1.6kb | 2024-05-28 20:44:32 | 2024-05-28 20:44:32 |
Judging History
answer
#include<bits/extc++.h>
#include<bits/stdc++.h>
//#pragma GCC optimize(2)
//本代码含有小众情感元素,建议满 18 周岁后观看
#ifdef __unix__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#else
#define getchar _getchar_nolock
#define putchar _putchar_nolock
#endif
#define debug(x) fprintf(stderr,"Line %d,%s=%lld\n",__LINE__,#x,(ll)x)
#define debugline fprintf(stderr,"--------------------------\n")
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define Inf (int)INFINITY
#define inf 0x3f3f3f3f
#define pb push_back
#define ll long long
#define endl '\n'
#define y second
#define x first
using namespace std;
const int N=1e6+10,mod=998244353;
void read(){};
template<class T1,class...T2>
inline void read(T1&ret,T2&...rest){
ret=0;char c=getchar();bool f=false;
while(c<'0'||c>'9')f=c=='-',c=getchar();
while(c>='0'&&c<='9')ret=ret*10+c-'0',c=getchar();
f&&(ret=-ret),read(rest...);
}
#define cin(...) read(__VA_ARGS__)
template<class T>
inline void print(T x){
static int s[35],t=0;
bool f=x<0;if(f)x=-x;
do s[t++]=x%10,x/=10;while(x);
f&&putchar('-');while(t)putchar(s[--t]+'0');
}
int n,k;
int q_pow(int a,int b){int res=1;for(;b;b>>=1){(b&1)&&(res=res*1ll*a%mod),a=a*1ll*a%mod;}return res;}
int phi(int n){
int res=n;
for(int i=2;i*i<=n;i++)
if(!(n%i)){
res=res/i*(i-1);
for(;!(n%i);n/=i);
}
if(n>1)res=res/n*(n-1);
return res;
}
int getc(int n,int m){
int c=1;
for(int i=1;i<=n&&i<=m;i++)
c=c*1ll*q_pow(i,mod-2)%mod*(n-i+1)%mod;
return c;
}
int main(){
cin(n,k),print(getc(n-1,k-1)*1ll*phi(n)%mod),putchar(endl);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3524kb
input:
4 1
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
9 2
output:
48
result:
ok 1 number(s): "48"
Test #3:
score: 0
Accepted
time: 26ms
memory: 3624kb
input:
222222222 222222
output:
851798824
result:
ok 1 number(s): "851798824"
Test #4:
score: -100
Time Limit Exceeded
input:
998244352 249561088