因为所有整数都能被唯一分解,p1^a1*p2^a2*...*pi^ai,而一次询问的数可以分解为p1^a1k*p2^a2k*...*pi^aik,这次询问会把所有a1>=a1k && a2 >= a2k &&...

a3 >= a3k的数从原来的集合中分开。ai表示pi的幂。

那么只有当这个数的素因子的最大幂都被询问过一次,这个数才能确定。因此答案是所有的不大于n的只有一个素因子的数。

#include<bits/stdc++.h>
using namespace std; const int maxn = 1e3+;
int prime[maxn];
bool vis[maxn];
int sieve(int n)
{
int m = sqrt(n+0.5);
for(int i = ; i <= m; i++) if(!vis[i]){
for(int j = i*i; j <= n; j+=i) vis[j] = true;
}
int c = ;
for(int i = ; i <= n; i++) if(!vis[i]){
prime[c++] = i;
}
return c;
} vector<int> ans;
int main()
{
int tot = sieve();
int n; scanf("%d",&n);
for(int i = ; i < tot; i++){
int p = prime[i];
if(p > n) break;
for(int t = p; t<=n; t*=p){
ans.push_back(t);
}
}
printf("%d\n",ans.size());
for(int i = ; i < ans.size(); i++){
if(i) putchar(' ');
printf("%d",ans[i]);
}
return ;
}

Codeforces Round #319 (Div. 2) C Vasya and Petya's Game (数论)的更多相关文章

  1. Codeforces Codeforces Round #319 (Div. 2) C. Vasya and Petya's Game 数学

    C. Vasya and Petya's Game Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...

  2. Codeforces Round #319 (Div. 2) C. Vasya and Petya's Game 数学

    C. Vasya and Petya's Game time limit per test 1 second memory limit per test 256 megabytes input sta ...

  3. 数学 - Codeforces Round #319 (Div. 1)A. Vasya and Petya's Game

    Vasya and Petya's Game Problem's Link Mean: 给定一个n,系统随机选定了一个数x,(1<=x<=n). 你可以询问系统x是否能被y整除,系统会回答 ...

  4. Codeforces Round #319 (Div. 2) C. Vasya and Petya's Game 数学题

                                                     C. Vasya and Petya's Game                           ...

  5. 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root

    题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algori ...

  6. Codeforces Round 319 # div.1 & 2 解题报告

    Div. 2 Multiplication Table (577A) 题意: 给定n行n列的方阵,第i行第j列的数就是i*j,问有多少个格子上的数恰为x. 1<=n<=10^5, 1< ...

  7. Codeforces Round #319 (Div. 2)

    水 A - Multiplication Table 不要想复杂,第一题就是纯暴力 代码: #include <cstdio> #include <algorithm> #in ...

  8. codeforces 576a//Vasya and Petya's Game// Codeforces Round #319 (Div. 1)

    题意:猜数游戏变种.先选好猜的数,对方会告诉你他想的那个数(1-n)能不能整除你猜的数,问最少猜几个数能保证知道对方想的数是多少? 对一个质数p,如果p^x不猜,那么就无法区分p^(x-1)和p^x, ...

  9. Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题

    A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

随机推荐

  1. VS13+OPCV2.4.11

    转载:http://blog.csdn.net/a934270082/article/details/50843266?locationNum=3&fps=1 1. 配置系统环境变量:计算机 ...

  2. SelectObject()函数详解

    SelectObject 把一个对象(位图.画笔.画刷等)选入指定的设备描述表.新的对象代替同一类型的老对象. HGDIOBJ SelectObject(   HDC hdc,          // ...

  3. 牛客想开了大赛2 A-【六】平面(切平面)

    A-[六]平面 链接:https://ac.nowcoder.com/acm/contest/907/A?&headNav=acm来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限 ...

  4. HDU - 5887 2016青岛网络赛 Herbs Gathering(形似01背包的搜索)

    Herbs Gathering 10.76% 1000ms 32768K   Collecting one's own plants for use as herbal medicines is pe ...

  5. EntityFramework数据库配置(code frist)

    什么也不说先贴代码 <?xml version="1.0" encoding="utf-8"?> <configuration> < ...

  6. Keras实现CIFAR-10分类

      仅仅为了学习Keras的使用,使用一个四层的全连接网络对MNIST数据集进行分类,网络模型各层结点数为:3072: : 1024 : 512:10:   使用50000张图片进行训练,10000张 ...

  7. 微调Inception V3网络-对Satellite分类

    目录 1. 流程概述 2. 准备数据集 2.1 Satellite数据集介绍 3. Inception V3网络 4. 训练 4.1 基于Keras微调Inception V3网络 4.2 Keras ...

  8. 3dmax视频

    http://wenku.baidu.com/course/list/514?tagID=177

  9. 优酷土豆的Redis服务平台化之路

    前言 Nginx 是一个 免费的 , 开源的 , 高性能 的 HTTP 服务器和 反向代理 ,以及 IMAP / POP3代理服务器. Nginx 以其高性能,稳定性,丰富的功能,简单的配置和低资源消 ...

  10. CF 1215解题报告

    T1 偶数输出n/2 奇数输出(n-1)/2即可 T2 判断是不是回文 不是直接输出子串 是回文继续判断 如果他前(len+1)/2内没有相同 输出-1 其他的 交换不同字符,输出子串 T3 贪心+二 ...