/*
http://codeforces.com/problemset/problem/449/C
cf 449 C. Jzzhu and Apples
数论+素数+贪心
*/
#include <cstdio>
#include <algorithm>
using namespace std;
const int Nmax=;
int is_prime[Nmax];
int book[Nmax];
int cnt[Nmax];
int n,ans;
void get__prime()
{
for(int i=;i<=n;i++)
is_prime[i]=;
for(int i=;i<=n;i++)
{
if(is_prime[i])
{
for(int j=;j*i<=n;j++)
{
is_prime[i*j]=;
}
}
}
} int main()
{
//freopen("cf449C.in","r",stdin);
scanf("%d",&n);
get__prime();
for(int i=n;i>=;i--)
{
if(is_prime[i])
{
cnt[i]=;
for(int j=;i*j<=n;j++)
{
if(!book[i*j])
{
cnt[i]++;
book[i*j]=;
}
}
if(cnt[i]&)
book[*i]=;
ans+=cnt[i]>>;
}
}
printf("%d\n",ans);
for(int i=;i<=n;i++)
book[i]=;
for(int i=n;i>=;i--)
{
if(is_prime[i] && cnt[i]>)
{
if(cnt[i]&)
{
int flag=;
for(int j=;i*j<=n;j++)
{
if(j==)
continue;
if(!book[i*j])
{
printf("%d",i*j);
if(flag)
printf(" ");
else
printf("\n");
flag^=;
book[i*j]=;
}
}
}
else
{
int flag=;
for(int j=;i*j<=n;j++)
{
if(!book[i*j])
{
printf("%d",i*j);
if(flag)
printf(" ");
else
printf("\n");
flag^=;
book[i*j]=;
}
}
}
}
}
return ;
}

CF449 C. Jzzhu and Apples的更多相关文章

  1. CF449C Jzzhu and Apples (筛素数 数论?

    Codeforces Round #257 (Div. 1) C Codeforces Round #257 (Div. 1) E CF450E C. Jzzhu and Apples time li ...

  2. Codeforces 449C Jzzhu and Apples 贪心 (看题解)

    Jzzhu and Apples 从大的质因子开始贪心, 如果有偶数个则直接组合, 如果是奇数个留下那个质数的两倍, 其余两两组合. #include<bits/stdc++.h> #de ...

  3. Codeforces Round #257 (Div. 2) E题:Jzzhu and Apples 模拟

    E. Jzzhu and Apples time limit per test 1 second memory limit per test 256 megabytes input standard ...

  4. Codeforces 449.C Jzzhu and Apples

    C. Jzzhu and Apples time limit per test 1 second memory limit per test 256 megabytes input standard ...

  5. CF 450E Jzzhu and Apples 数学+模拟

    E. Jzzhu and Apples time limit per test 1 second memory limit per test 256 megabytes input standard ...

  6. Codeforces 450E:Jzzhu and Apples(构造,数学)

    E. Jzzhu and Apples time limit per test: 1 seconds memory limit per test: 256 megabytes input: stand ...

  7. Codeforces Round #257 (Div. 1) C. Jzzhu and Apples (素数筛)

    题目链接:http://codeforces.com/problemset/problem/449/C 给你n个数,从1到n.然后从这些数中挑选出不互质的数对最多有多少对. 先是素数筛,显然2的倍数的 ...

  8. CF449C:Jzzhu and Apples

    题意简述 给出正整数n,你要把1-n之间的正整数分成尽可能多组,使得每一组两个数的最大公约数大于1;输出能分成最多组的个数,并按任意顺序输出每组的两个数. 很妙的一道题. 首先我们考虑去处理每个质数的 ...

  9. Jzzhu and Apples CodeForces - 449C (构造,数学)

    大意: 求从[1,n]范围选择尽量多的数对, 使得每对数的gcd>1 考虑所有除2以外且不超过n/2的素数p, 若p倍数可以选择的有偶数个, 直接全部划分即可 有奇数个的话, 余下一个2*p不划 ...

随机推荐

  1. Intent 使用方法全面总结

    调用拨号程序 // 给移动客服10086拨打电话 Uri uri = Uri.parse("tel:10086"); Intent intent = new Intent(Inte ...

  2. 【cocos2d-x 3.7 飞机大战】 决战南海I (八) 背景移动

    採用双层背景.这样效果更好 .h class BackgroundMove : public Layer { public: BackgroundMove(); ~BackgroundMove(); ...

  3. 分享一个iOS输入框特殊限制的代码 UITextField (Validation)

    //个人总结.欢迎新增或改动 #import <UIKit/UIKit.h> typedef enum{ VALIDATION_TYPE_NUM_VALIDATED = 0,//数字 VA ...

  4. HTTP缓存和CDN缓存

    一 http缓存 1.1缓存的分类: http中具有缓存功能的是:1.浏览器缓存.  2.缓存代理服务器. 1.2 什么是缓存: http缓存的是指:当Web请求抵达缓存时, 如果本地有“已缓存的”副 ...

  5. ios开发之Swift新手入门

    1.关于swift和调试,swift在ios7.0才支持,ios8.3系统的真机必需要xcode6.3才干调试.安装xcode6.3需要os x 10.10以上 2.应用程序由Main.storybo ...

  6. PHP中数据类型转换的三种方式

    PHP中数据类型转换的三种方式 PHP的数据类型转换属于强制转换,允许转换的PHP数据类型有: 1.(int).(integer):转换成整形2.(float).(double).(real):转换成 ...

  7. VM虚拟机-Windows

    前提:安装了vm虚拟机 一.下载win10原版镜像文件 一定要是原版,修改版的不能用. 推荐下载网址:http://www.xitongtiandi.net/win10yuanban/ 下载后放在D盘 ...

  8. Hadoop MapReduce编程 API入门系列之多个Job迭代式MapReduce运行(十二)

    推荐 MapReduce分析明星微博数据 http://git.oschina.net/ljc520313/codeexample/tree/master/bigdata/hadoop/mapredu ...

  9. 1.Ventuz 介绍

    Ventoz能做什么? Ventuz是一款实时图文包装内容创作.制作和播出控制软件.Ventuz专注于高端视听内容的制作,包括交互展示和大型活动.视频墙.广播电视在线包装及演播室舞台及灯光控制等领域. ...

  10. C#监测方法执行效率

    System.Diagnostics.Stopwatch watch = new Stopwatch(); watch.Start(); // 开始监视代码运行时间 //需要监测的代码 dothing ...