# CF 577C Vasya and Petya ' s Game

Source: Internet
Author: User

Test instructions: A game, a children's shoes in the range of 1~n guess a number, b children's shoes to ask a set, a children's shoes to answer each number in the collection, he guessed whether the number can be divided, b to get a guess by these answers to the number, the minimum number of guesses to guess?

Solution: A number can be multiplied by the exponential Shan of several prime numbers, so the answer to all numbers can be obtained by asking the exponential power of all prime numbers less than N.

Code:

`#include <stdio.h> #include <iostream> #include <algorithm> #include <string> #include < string.h> #include <math.h> #include <limits.h> #include <time.h> #include <stdlib.h># include<map> #include <queue> #include <set> #include <stack> #include <vector> #define LL    Long longusing namespace Std;vector <int> prime;void init () {bool isprime[1005] = {0};            for (int i = 2; I <=, i++) {if (!isprime[i]) {prime.push_back (i);        for (int j = i + i; j <=; J + = i) isprime[j] = 1;    }}}int Main () {init ();    int n;        while (~SCANF ("%d", &n)) {vector <int> ans;            for (int i = 0; i < prime.size (); i++) {int tmp = Prime[i];                while (TMP <= N) {ans.push_back (TMP);            TMP *= Prime[i];        }} cout << ans.size () << Endl; for (int i = 0; I < Ans.size ();            i++) {if (i) printf ("");        cout << Ans[i];    } puts (""); } return 0;}`

CF 577C Vasya and Petya ' s Game

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.