QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#500055 | #6956. Many Topological Problems | inksamurai | AC ✓ | 51ms | 3640kb | C++23 | 1.6kb | 2024-07-31 21:37:15 | 2024-07-31 21:37:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int) a.size()
#define all(a) a.begin(),a.end()
#define vec(...) vector<__VA_ARGS__>
#define _3Wcdivh ios::sync_with_stdio(0),cin.tie(0)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}
// snuke's mod int
template <ll mod>
struct modint{
ll x;
modint(ll x=0):x((x%mod+mod)%mod){}
modint operator-()const{return modint(-x);}
modint& operator+=(const modint a){if((x+=a.x)>=mod) x-=mod; return *this;}
modint& operator-=(const modint a){if((x+=mod-a.x)>=mod) x-=mod; return *this;}
modint& operator*=(const modint a){(x*=a.x)%=mod; return *this;}
modint operator+(const modint a)const{modint res(*this); return res+=a;}
modint operator-(const modint a)const{modint res(*this); return res-=a;}
modint operator*(const modint a)const{modint res(*this); return res*=a;}
modint pow(ll n)const{
modint res=1,x(*this);
while(n){
if(n&1)res*=x;
x*=x;
n>>=1;
}
return res;
}
modint inv()const{return pow(mod-2);}
};
using mint=modint<1000000007>;
void slv(){
int n,k;
cin>>n>>k;
mint ans=1;
for(int i=2;i<=n;i++){
ans*=mint(min(i-1,k));
}
for(int i=1;i<=n;i++){
ans*=mint(i);
}
print(ans.x);
}
signed main(){
_3Wcdivh;
int __t;
cin>>__t;
rep(cs,__t){
slv();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 51ms
memory: 3640kb
input:
10 1 1 700503 623646 939811 584922 752155 569391 348265 116258 839298 839298 800391 216447 150847 116426 370812 168588 1000000 407619
output:
1 972550684 617838838 561525568 470024873 910196299 782371500 133886363 868118624 262962652
result:
ok 10 lines