E - Cup 2 dfs memory search

Description

The European Cup final is coming. The past two World Cup winners, Spain and Italy, will contest the decider at Kiev's Olympic Stadium. Italy-Spain Euro final promises to be clash of polar opposites, so it's difficult to say which team will win.

Now there are M fans in ZJU, N of them support Italy. Suppose you are the president of the students' union and you support Italy. You can divide these M fans into s1 groups(Level 1). More than half of the group(Level 1) support Italy ,than you can say it seems all the Mfans support Italy. You can also divide each group(Level 1) into s2 groups(Level 2). More than half of the group(Level 2) support Italy ,than you can say this group(Level 1) support Italy. ... .You can also divide each group(Level i) into s(i+1) groups(Level i+1). More than half of the group(Level i+1) support Italy ,than you can say this group(Level i) support Italy. To be fair, every group(Level i) has the same number of person. Can you find an suitable way to arrange these N person so that all these M fans seem to support Italy.

Input

Mutiple test cases, process to the end of file.
Each case has a single line with two integer M , N (1<=M,N<=100000000).

Output

For each case:
The firt line output Yes if you can do the task or No for not. The second line output the minimum person you need.

Sample Input

4 3
12 5

Sample Output

Yes 
3 
No 
6 
********************************************** ************************************************** ************************************************** *********
enumerate all of the groups, memories search
******************************** ************************************************** ************************************************** ********************* U *
 1 #include<iostream>
 2 #include<string>
 3 #include<cstring>
 4 #include<cmath>
 5 #include<cstdio>
 6 #include<map>
 7 using namespace std;
 8 map<int,int>ans;
 9 int n,m;
10 int dfs(int n)
11 {
12   int MIN=n/2+1;
13   int it;
14   if(ans.count (n-))
 15      return ANS [n-];
 16    for (IT = 2 ; IT IT * <= n-; IT ++ )
 . 17    {
 18 is      IF (IT% n-== 0 ) // enumerate all packets 
. 19      {
 20 is          mIN = min (mIN, ((n-/ IT) / 2 + . 1 ) * DFS (IT));
 21 is          mIN = min (mIN, (IT / 2 + . 1 ) * DFS (n-/ IT));
 22 is      }
 23 is    }
 24    ANS [n-] = MIN; // divided into groups corresponding to the required minimum 
25    return MIN;
 26 is }
27 int main()
28 {
29     while(scanf("%d %d",&n,&m)!=EOF)
30     {
31         int  MIN=dfs(n);
32         if(MIN<=m)
33             puts("Yes");
34         else
35             puts("No");
36         printf("%d\n",MIN);
37     }
38     return 0;
39 }
View Code

 

Reproduced in: https: //www.cnblogs.com/sdau--codeants/p/3444324.html

Guess you like

Origin blog.csdn.net/weixin_34318272/article/details/93432899