2015安徽省赛 H.数7

时间:2023-03-08 22:15:44

http://xcacm.hfut.edu.cn/problem.php?id=1212

模拟大发

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
bool judge_prime(int k)
{
int i;
int u=int(sqrt(k*1.0));
for(i=;i<=u;i++)
{
if(k%i==)
return ;
}
return ;
}
int main()
{
int i,j,m,n,T,a,b;
scanf("%d",&T);
while(T--)
{
scanf("%d%d%d%d",&n,&m,&a,&b);
bool good=false,hello=false;
while()
{
if(a>n) a=;
if(a<) a=n;
hello=judge_prime(b);
if(a==m)
{
if(hello)
{
cout<<"duang"<<endl;
break;
}
else
{
cout<<b<<endl;
break;
}
}
if(hello)
{
if(good==true) good=false;
else good=true;
}
if(good==false)
{
a++;
b++;
}
else if(good==true)
{
a--;
b++;
}
}
}
return ;
}