玄学问题
  • 板块灌水区
  • 楼主mrozhx
  • 当前回复9
  • 已保存回复9
  • 发布时间2020/8/14 11:31
  • 上次更新2023/11/6 20:20:46
查看原帖
玄学问题
150611
mrozhx楼主2020/8/14 11:31

这两段代码不应该等价吗,但第二段代码的得分要AC少一个点

#include<bits/stdc++.h>
using namespace std;
long long l,u;
int main(){
	long long am=0,maxn=0,num=0,nowz=0;
	cin>>l>>u;
	for(int i=l;i<=u;i++){
		for(int j=1;j*j<=i;j++){
			if(i%j==0) nowz+=2;
			if(j*j==i) nowz--;
		}
		if(nowz>maxn) maxn=nowz,num=i;
		nowz=0; 
	}
	cout<<"Between "<<l<<" and "<<u<<", "<<num<<" has a maximum of "<<maxn<<" divisors.";
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
long long l,u;
int main(){
	long long am=0,maxn=0,num=0,nowz=0;
	cin>>l>>u;
	for(int i=l;i<=u;i++){
		for(int j=1;j*j<i;j++){
			if(i%j==0) nowz++;
		}
		nowz*=2;
		if(sqrt(i)*sqrt(i)==i) nowz++;
		if(nowz>maxn) maxn=nowz,num=i;
		nowz=0; 
	}
	cout<<"Between "<<l<<" and "<<u<<", "<<num<<" has a maximum of "<<maxn<<" divisors.";
	return 0;
}
2020/8/14 11:31
加载中...