Codeforces Round #319 (Div. 1)
来源:互联网 发布:python如何连接小票机 编辑:程序博客网 时间:2024/06/04 18:22
思维题。。然而就是不会啊!太菜了
我们发现对于一个能够分出来两个不同质因数的数我们只要对质因数及质因数的几次幂进行询问即可确定该数。
所以我们把目光放在质因数上。
假设我们询问了n以下所有质因数的一次幂,形如Pi,则我们一定不能确定Pi2,P3i,P4i.....
如果紧接着询问了所有质因数的二次幂,形如P2i,则我们一定不能确定Pi3,P4i.......
所以经由上面的规律寻找大概猜测我们要询问所有质因子的x次幂,并且该质因子的x次幂小于等于n。
大概脑补可以想象正确性。
直接暴力搞就行
#include<cstdio>#include<cstdlib>#include<iostream>#include<stack>#include<queue>#include<algorithm>#include<string>#include<cstring>#include<cmath>#include<vector>#include<map>#include<set>#define eps 1e-8#define zero(x) (((x>0?(x):-(x))-eps)#define mem(a,b) memset(a,b,sizeof(a))#define memmax(a) memset(a,0x3f,sizeof(a))#define pfn printf("\n")#define ll __int64#define ull unsigned long long#define sf(a) scanf("%d",&a)#define sf64(a) scanf("%I64d",&a)#define sf264(a,b) scanf("%I64d%I64d",&a,&b)#define sf364(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c)#define sf464(a,b,c,d) scanf("%I64d%I64d%I64d%I64d",&a,&b,&c,&d)#define sf564(a,b,c,d,ee) scanf("%I64d%I64d%I64d%I64d%I64d",&a,&b,&c,&d,&ee)#define sf2(a,b) scanf("%d%d",&a,&b)#define sf3(a,b,c) scanf("%d%d%d",&a,&b,&c)#define sf4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)#define sf5(a,b,c,d,ee) scanf("%d%d%d%d%d",&a,&b,&c,&d,&ee)#define sff(a) scanf("%f",&a)#define sfs(a) scanf("%s",a)#define sfs2(a,b) scanf("%s%s",a,b)#define sfs3(a,b,c) scanf("%s%s%s",a,b,c)#define sfd(a) scanf("%lf",&a)#define sfd2(a,b) scanf("%lf%lf",&a,&b)#define sfd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)#define sfd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)#define sfc(a) scanf("%c",&a)#define ull unsigned long long#define pp pair<int,int>#define debug printf("***\n")#define pi 3.1415927#define mod 1000000007#define rep(i,a,b) for(int i=a;i<b;i++)const double PI = acos(-1.0);const double e = exp(1.0);const int INF = 0x7fffffff;;template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }template<class T> inline T Min(T a, T b) { return a < b ? a : b; }template<class T> inline T Max(T a, T b) { return a > b ? a : b; }bool cmpbig(int a, int b){ return a>b; }bool cmpsmall(int a, int b){ return a<b; }using namespace std;int main(){ // freopen("data.in","r",stdin); //freopen("data.out" ,"w",stdout); int n; int heshu[1010]; mem(heshu,0); for(int i=2;i*i<=1000;i++) for(int j=i;j*i<=1000;j++) heshu[i*j]=1; while(~sf(n)) { vector<int>flag; flag.clear(); rep(i,2,n+1) { if(heshu[i]) continue; int p=i; while(p<=n) { flag.push_back(p); p*=i; } } cout<<flag.size()<<endl; rep(i,0,flag.size()) cout<<flag[i]<<" "; pfn; } return 0;}
0 0
- Codeforces Round #319 (Div. 1)
- Codeforces Round #319 (Div. 1) 简要记录
- Codeforces Round #319 (Div. 2)
- Codeforces Round #319 (Div. 2)
- Codeforces Round #110 (Div. 1)
- Codeforces Round #138 (Div. 1)
- Codeforces Round #140 (Div. 1)
- Codeforces Round #153 (Div. 1)
- Codeforces Round #157 (Div. 1)
- Codeforces Round #160 (Div. 1)
- Codeforces Round #162 (Div. 1)
- Codeforces Round #165 (Div. 1)
- Codeforces Round #165 (Div. 1)
- Codeforces Round #167 (Div. 1)
- Codeforces Round #168 (Div. 1)
- Codeforces Round #174 (Div. 1)
- Codeforces Round #187 DIV 1
- Codeforces Round #198 (Div. 1)
- Fatal error: Can't use function return value in write context in
- java事物的理解
- PHP中关于Excel的使用
- Linux系统中crontab定时器设置
- es 数据 导出 到 MySQL
- Codeforces Round #319 (Div. 1)
- 如何配置sigar在Linux和Windows下使用java语言获得各种系统信息
- Google WomenTechmakers(北京区)感悟
- 因果图与判定表法
- 九度OJ题目1001:A+B for Matrices
- spring @Scheduled cron表达式
- java创建txt文件并存入内容
- Git多账号配置及SSH-KEY管理
- Hystrix配置介绍