C. Vasya and Petya's Game Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/577/problem/C Description Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the number. P…
C. Vasya and Petya's Game time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the…
Vasya and Petya's Game Problem's Link Mean: 给定一个n,系统随机选定了一个数x,(1<=x<=n). 你可以询问系统x是否能被y整除,系统会回答"Yes"or“No". 问:至少询问多少次可以唯一确定x,并输出询问序列.(special judge). analyse: 做法:求质数的整数次幂(不大于n). 思路:首先我们肯定是用质数来判断,因为质数排除的是最多的. 如果质数p[i]能够整除,那么x有可能是p[i]^2,…
链接 某个数x属于[1,n],至少询问哪些数“x是否是它的倍数”才能判断x.找出所有质因数和质因数的幂即可. #include<cstdio> #include<algorithm> #define N 1005 using namespace std; int n,pr[N],ans[N],cnt; int main(){ scanf("%d",&n); for(int i=2;i<=n;i++) if(!pr[i]) for(int j=i*2…