#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 100010;
LL a,b,c,d;
int main()
{
cin>>a>>b>>c>>d;
LL ans = max(abs(a-c),abs(b-d));
cout<<ans;
return 0;
}
4874. 约数
一个数若只有三个因数,则它必定是一个素数的平方。
使用线性筛
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 100010;
//简单线性筛
int n;
int p[N],cnt = 0;
bool st[N];
int main()
{
memset(st,true,sizeof st);
st[1] = false;
for(int i = 2;i <= 1000000;i++){
if(st[i]) p[++cnt] = i;
for(int j = 1;p[j] * i <= 1000000;j++){
st[p[j] * i] = false;
if(i % p[j] == 0) break;
}
}
cin>>n;
while(n--){
LL x;
cin>>x;
LL t = sqrt(x);
if(t*t == x && st[x]) puts("YES");
else put("NO");
}
return 0;
}