https://www.luogu.com.cn/problem/T340361?contestId=112201题目,只有11分
#include<bits/stdc++.h>
using namespace std;
bool cxys(int n,int d){
if(d==1){
return false;
}
int a=1;
for(int i=1;i<=n;i++){
a*=i;
if(a+1==d){
return true;
}
if(a+1!=d) {
return false;
}
}
return false;
}
int main(){
int t;
cin>>t;
for(int i=1;i<=t;i++){
int d,n;
cin>>d>>n;
if(cxys(n,d)){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
}
return 0;
}