571

# 题目

There is a kindom of obsession, so people in this kingdom do things very strictly.

They name themselves in integer, and there are n people with their id continuous (s+1,s+2, ,s+n) standing in a line in arbitrary order, be more obsessively, people with id x wants to stand at yth position which satisfy

x mod y=0

Is there any way to satisfy everyone's requirement

First line contains an integer T, which indicates the number of test cases.

Every test case contains one line with two integers n, s.

Limits
1≤T≤100.
1≤n≤109.
0≤s≤109.

For every test case, you should output 'Case #x: y', where x indicates the case number and counts from 1 and y is the result string.

If there is any way to satisfy everyone's requirement, y equals 'Yes', otherwise y equals 'No'.

2
5 14
4 11

Case #1: No
Case #2: Yes

# 题解

(都要放在 1 的位置上)

1. 对于一组数据的每一个数据都进行判断是否为素数,当找到 2 个以上时,直接跳出循环
2. 找到 109 素数间隔的最大值,只在小于时计算

(已经可以预知,不管怎么样,如果方案 2 都超时,方案 1 必定超时)

(当然,通过其他的判断也可以解决)

# 代码

`cpp Kingdom of Obsession https://github.com/OhYee/sourcecode/tree/master/ACM 代码备份
/*
#define debug
#include
//*/

#include
#include
#include
#include
#include
using namespace std;

typedef long long LL;

/*
• 匈牙利算法邻接表形式
• 使用前用init()进行初始化，给uN赋值
• */
const int MAXN = 2005;//点数的最大值
const int MAXM = MAXN*MAXN;//边数的最大值
struct Edge {
}edge[MAXM];

void init(int un) {
uN = un;
tot = 0;
}

edge[tot].to = v;
}

bool used[MAXN];
bool dfs(int u) {
for(int i = head[u]; i != -1;i = edge[i].next){
int v = edge[i].to;
if(!used[v]){
used[v] = true;
return true;
}
}
}
return false;
}
int hungary(){
int res = 0;
for(int u = 0; u < uN;u++){//点的编号0~uN-1
memset(used,false,sizeof(used));
if(dfs(u))
res++;
}
return res;
}

bool Solve(int n,int s){
if(sif(n>1000) return false;

//匈牙利算法 求解二分图
init(n);
for(int i=1;i<=n;i++){
LL t = (LL)i+(LL)s;
for(int j=1;j<=n;j++){
if(t%j==0)
}
}
//cout<return hungary()==n;
}

int main(){
#ifdef debug
freopen("in.txt", "r", stdin);
int START = clock();
#endif

int T;
cin>>T;
for(int kase=1;kase<=T;kase++){
int n,s;
cin>>n>>s;
cout<<"Case #"<}

#ifdef debug
printf("Time:%.3lfsn", double(clock() - START) / CLOCKSPERSEC);
#endif
return 0;
}

• 点击查看/关闭被识别为广告的评论