请求大佬教一下其中数学原理,回关,谢
查看原帖
请求大佬教一下其中数学原理,回关,谢
1008115
cinemaaa楼主2023/8/26 20:25
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int tot,n,tot1=0;
	cin>>n;
	for(int k=2;k<n;k++){
		if(n%k==0) tot1++;
	}
	if(tot1==0){
		cout<<fixed<<setprecision(0);
		cout<<pow(2,n-1);
		return 0;
	}
	for(int i=n;;){
		tot=1;
		for(int k=1;k*2<=i;k++){
			if(i%k==0) tot++;
		}
				if(tot!=n){
				i++;
				continue;
				}
				cout<<i;
				return 0;
	}
}
2023/8/26 20:25
加载中...