刚才比赛的t2求改,悬一关啊啊!!!
  • 板块灌水区
  • 楼主kn_wlq
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/7/9 17:07
  • 上次更新2023/11/3 10:53:36
查看原帖
刚才比赛的t2求改,悬一关啊啊!!!
753554
kn_wlq楼主2023/7/9 17:07

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;
}

2023/7/9 17:07
加载中...