链接

某个数x属于[1,n],至少询问哪些数y“x是否是y的倍数”才能判断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;j<=n;j+=i)
pr[j]++;
for(int i=2;i<=n;i++)
if(pr[i]<2)
ans[cnt++]=i;
printf("%d\n",cnt);
for(int i=0;i<cnt;i++)
printf("%d ",ans[i]);
}

  

【CodeForces 577C】Vasya and Petya’s Game的更多相关文章

  1. 【Codeforces 1030D】Vasya and Triangle

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 参考这篇题解:https://blog.csdn.net/mitsuha_/article/details/82825862 为什么可以保证m ...

  2. 【Codeforces 493C】Vasya and Basketball

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 枚举三分线(离散后)的位置 然后根据预处理的前缀和,快速算出两个队伍的分数. [代码] #include <bits/stdc++.h& ...

  3. 【Codeforces 493D】Vasya and Chess

    [链接] 我是链接,点我呀:) [题意] [题解] 会发现两个皇后之间如果只有奇数个位置 也就是n%2==1 那么第二个人总是赢的 因为如果white往下跑的话,black也能往下跑. 第二个人没有输 ...

  4. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  5. 【44.10%】【codeforces 723B】Text Document Analysis

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  6. 【22.70%】【codeforces 591C】 Median Smoothing

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  7. 【23.26%】【codeforces 747D】Winter Is Coming

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  9. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

随机推荐

  1. uva10160 Servicing Stations

    The input consists of more than one description of town (but totally, less than ten descriptions). E ...

  2. stl学习(一)优先队列

    优先队列priority queue 头文件 #include<queue> 优先队列,也就是原来我们学过的堆,按照自己定义的优先级出队时.默认情况下底层是以Vector实现的heap. ...

  3. 关于Kendo UI的使用心得

    1.在筛选里面的条件选项进行编辑 filterable: { extra: false, operators: { string: { startswith: "Starts with&qu ...

  4. 加载cocos studio场景

    今天尝试加载cocos studio的场景. 新版的cocos studio中,"导出"选项变成了"发布".发布之后会生成一个res文件夹,其中每个场景有一个. ...

  5. Notes: Principles of fMRI 1 (Coursera)

    course link: https://class.coursera.org/fmri1-001 Part 1  ❤ Three fundmental goals in fMRI: localiza ...

  6. SharePoint GroupedItemPicker Control

    这个控件SharePoint用来选择Field ,和Content Type, 以下是一个完整的示例. <SharePoint:GroupedItemPicker ID="Select ...

  7. 1002. A+B for Polynomials

    1002. A+B for Polynomials (25) This time, you are supposed to find A+B where A and B are two polynom ...

  8. scala 学习笔记(03) 参数缺省值、不定个数参数、类的属性(Property)、泛型初步

    继续学习,这一篇主要是通过scala来吐槽java的,同样是jvm上的语言,差距咋就这么大呢? 作为一个有.NET开发经验的程序员,当初刚接触java时,相信很多人对java语言有以下不爽(只列了极小 ...

  9. javascript: 带分组数据的Table表头排序

    如下图: 要求:点击表头排序时,"分组"及"分组明细"的数据层次关系不变 从网上找了一段常规的table排序,改了改,以满足“分组支持”,贴在这里备份 < ...

  10. 【深入ASP.NET原理系列】--Asp.Net Mvc和Asp.Net WebForm共用一套ASP.NET请求管道

    .NET FrameWork4在系统全局配置文件(如在如下目录中C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config) 中添加了一个名字叫Url ...