QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#487943 | #6634. Central Subset | ucup-team052# | WA | 150ms | 159996kb | C++23 | 2.1kb | 2024-07-23 13:44:45 | 2024-07-23 13:44:45 |
Judging History
answer
#include<bits/stdc++.h>
#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#define DD(...) D(#__VA_ARGS__ "="),debug_helper::debug(__VA_ARGS__),D("\n")
#include"/home/xay5421/debug.hpp"
#else
#define D(...) ((void)0)
#define DD(...) ((void)0)
#endif
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define each(x,v) for(auto&x:v)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
template<class T>void rd(T&x){int f=0,c;while(!isdigit(c=getchar()))f^=!(c^45);x=(c&15);while(isdigit(c=getchar()))x=x*10+(c&15);if(f)x=-x;}
template<class T>void pt(T x,int c=-1){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);if(c!=-1)putchar(c);}
using namespace std;
using LL=long long;
using ULL=unsigned long long;
const int P=1e9+7;
int ad(int k1,int k2){return k1+k2>=P?k1+k2-P:k1+k2;}
int su(int k1,int k2){return k1-k2<0?k1-k2+P:k1-k2;}
int mu(int k1,int k2){return 1ULL*k1*k2%P;}
void uad(int&k1,int k2){(k1+=k2)>=P&&(k1-=P);}
void usu(int&k1,int k2){(k1-=k2)<0&&(k1+=P);}
template<class... T>int ad(int k1,T... k2){return ad(k1,ad(k2...));}
template<class... T>int su(int k1,T... k2){return su(k1,ad(k2...));}
template<class... T>int mu(int k1,T... k2){return mu(k1,mu(k2...));}
template<class... T>void uad(int&k1,T... k2){return uad(k1,ad(k2...));}
template<class... T>void usu(int&k1,T... k2){return usu(k1,ad(k2...));}
int po(int k1,int k2){
int k3=1;
for(;k2;k2>>=1,k1=mu(k1,k1))if(k2&1)k3=mu(k3,k1);
return k3;
}
const int N=20000005;
int T,fac[N],ifac[N];
int C(int n,int m){
if(m<0||n<m)return 0;
return mu(fac[n],ifac[m],ifac[n-m]);
}
int calc(int x,int y){
return su(C(x,(x+y)/2),C(x,(x+y)/2+1));
}
int main(){
fac[0]=1;
rep(i,1,N-1)fac[i]=mu(fac[i-1],i);
ifac[N-1]=po(fac[N-1],P-2);
per(i,N-1,1)ifac[i-1]=mu(ifac[i],i);
rd(T);
while(T--){
int n,c;
rd(n),rd(c);
int ans=0;
rep(i,1,n){
int ret=mu(po(c,i),po(c-1,n-i),calc(n*2-i,i));
D("%d %d\n",mu(po(c,i),po(c-1,n-i)),calc(n*2-i,i));
uad(ans,ret);
}
printf("%d\n",ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 150ms
memory: 159996kb
input:
2 4 3 1 2 2 3 3 4 6 7 1 2 2 3 3 1 1 4 4 5 5 6 6 4
output:
957 2
result:
wrong answer Integer 957 violates the range [1, 2] (test case 1)