链接

某个数x属于[1,n],至少询问哪些数y“x是否是y的倍数”才能判断x。
找出所有质因数和质因数的幂即可。

  1. #include<cstdio>
  2. #include<algorithm>
  3. #define N 1005
  4. using namespace std;
  5. int n,pr[N],ans[N],cnt;
  6. int main(){
  7. scanf("%d",&n);
  8. for(int i=2;i<=n;i++)
  9. if(!pr[i])
  10. for(int j=i*2;j<=n;j+=i)
  11. pr[j]++;
  12. for(int i=2;i<=n;i++)
  13. if(pr[i]<2)
  14. ans[cnt++]=i;
  15. printf("%d\n",cnt);
  16. for(int i=0;i<cnt;i++)
  17. printf("%d ",ans[i]);
  18. }

  

【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. 转: windows 10使用原生linux bash命令行

    转: https://www.zybuluo.com/pandait/note/337430 windows 10使用原生linux bash命令行 linux bash windows-10 第一时 ...

  2. 关于oracle with as用法

    with as语法–针对一个别名with tmp as (select * from tb_name) –针对多个别名with   tmp as (select * from tb_name),   ...

  3. 如何用javac 和java 编译运行整个Java工程 (转载)【转】在Linux下编译与执行Java程序

    如何用javac 和java 编译运行整个Java工程 (转载)  http://blog.csdn.net/huagong_adu/article/details/6929817 [转]在Linux ...

  4. 配置Supervisor开机启动

    配置Supervisor开机启动: 新建一个"supervisord.service"文件 # dservice for systemd (CentOS 7.0+) # by ET ...

  5. Mysql备份系列(2)--mysqldump备份(全量+增量)方案操作记录

    在日常运维工作中,对mysql数据库的备份是万分重要的,以防在数据库表丢失或损坏情况出现,可以及时恢复数据. 线上数据库备份场景:每周日执行一次全量备份,然后每天下午1点执行MySQLdump增量备份 ...

  6. three.js 之旅 (三)

    复制自:http://www.cnblogs.com/ssrsblogs/p/5611332.html 创建模型: 1.长方体: THREE.CubeGeometry(width, height, d ...

  7. MIPAV - Talairach ACPC transform

    源地址:http://blog.sina.com.cn/s/blog_64cfe24f0100h358.html 1.打开MIPAV软件,File>open image from disk> ...

  8. PHP中$_SERVER的详细参数与说明

    $_SERVER['PHP_SELF'] #当前正在执行脚本的文件名,与 document root相关. $_SERVER['argv'] #传递给该脚本的参数. $_SERVER['argc'] ...

  9. NET WebApi OWIN 实现 OAuth 2.0

    NET WebApi OWIN 实现 OAuth 2.0 OAuth(开放授权)是一个开放标准,允许用户让第三方应用访问该用户在某一网站上存储的私密的资源(如照片,视频,联系人列表),而无需将用户名和 ...

  10. codevs 1051 接龙游戏

    codevs 1051 接龙游戏 http://codevs.cn/problem/1051/ 题目描述 Description 给出了N个单词,已经按长度排好了序.如果某单词i是某单词j的前缀,i- ...