【CodeForces 577C】Vasya and Petya’s Game
链接
某个数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的更多相关文章
- 【Codeforces 1030D】Vasya and Triangle
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 参考这篇题解:https://blog.csdn.net/mitsuha_/article/details/82825862 为什么可以保证m ...
- 【Codeforces 493C】Vasya and Basketball
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 枚举三分线(离散后)的位置 然后根据预处理的前缀和,快速算出两个队伍的分数. [代码] #include <bits/stdc++.h& ...
- 【Codeforces 493D】Vasya and Chess
[链接] 我是链接,点我呀:) [题意] [题解] 会发现两个皇后之间如果只有奇数个位置 也就是n%2==1 那么第二个人总是赢的 因为如果white往下跑的话,black也能往下跑. 第二个人没有输 ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【44.10%】【codeforces 723B】Text Document Analysis
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【22.70%】【codeforces 591C】 Median Smoothing
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【23.26%】【codeforces 747D】Winter Is Coming
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
随机推荐
- GNU Trove trove4j
GNU Trove (http://trove4j.sourceforge.net/) 是一个Java 集合类库.在某些场景下,Trove集合类库提供了更好的性能,而且内存使用更少.以下是Trove中 ...
- some basic graph theoretical measures
· mean characteristic path length calculated as the average length of the shortest path between two ...
- ValidateAntiForgeryToken 防止CSRF(跨网站请求伪造)
用途:防止CSRF(跨网站请求伪造). 用法:在View->Form表单中:<%:Html.AntiForgeryToken()%> 在Controller->Action动作 ...
- Post model至Web Api
Post model可以解决多动态性的参数至Web Api中去,获取数据或是创建数据.如果一个对象有很多字段,需要对每一个字段进行查询或是在创建对象时,我们可以考虑使用model来作参数.这样不必在控 ...
- [转]❲阮一峰❳Linux 守护进程的启动方法
❲阮一峰❳Linux 守护进程的启动方法 "守护进程"(daemon)就是一直在后台运行的进程(daemon). 本文介绍如何将一个 Web 应用,启动为守护进程. 一.问题的由来 ...
- http://kb.cnblogs.com/zt/ef/
http://kb.cnblogs.com/zt/ef/ http://blog.csdn.net/mackz/article/details/8605063 http://www.telerik.c ...
- 【转】加快网站访问速度——Yslow极限优化
Yslow是一套雅虎的网页评分系统,详细的列出了各项影响网页载入速度的参数,这里不做多说. 我之前就一直参考Yslow做博客优化,经过长时间的学习也算是有所收获,小博的YslowV2分数达到了94分( ...
- async 更优雅异步体验
上一篇<让 Generator 自启动>介绍了通过起动器让 Generator 跑起来,而本篇采用 async 实现更优雅的异步编程. 从例子开始 借用上一篇例子中的例子说起. funct ...
- 深入理解 cocos2d-x 坐标系
首先对于初学的,带大家认识 cocos2d-x 中坐标系的几个概念,参考 http://blog.csdn.net/tskyfree/article/details/8292544.其他的往下看. 弄 ...
- Bootstrap系列 -- 8. 代码显示
一. Bootstrap中的代码块 代码块一般在博客中使用的较多,比较博客园中提供的贴代码. 在Bootstrap中提供了三种形式的代码显示 1. 使用<code></code> ...