[乱搞] Codeforces 73E Beta Round #66 E. Morrowindows
来源:互联网 发布:保护java源代码的程序 编辑:程序博客网 时间:2024/05/17 23:16
远古乱搞题
我们发现选择一个
坑点多多 我是败在没有特判
其实还有
#include<cstdio>#include<cstdlib>#include<algorithm>using namespace std;typedef long long ll;inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;}inline void read(int &x){ char c=nc(),b=1; for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1; for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;}const int N=5000005,mP=N/10;bool vst[N];int prime[mP],num;inline void Pre(int n){ for (int i=2;i<=n;i++){ if (!vst[i]) prime[++num]=i; for (int j=1;j<=num && (ll)prime[j]*i<=n;j++){ vst[prime[j]*i]=1; if (i%prime[j]==0) break; } }}int tag[N],a[N];int main(){ int n,x; freopen("a.in","r",stdin); freopen("a.out","w",stdout); read(n); read(x); int flag=0; for (int i=1;i<=n;i++) read(a[i]),flag|=a[i]==1; if (flag && x>2) return printf("1\n"),0; if (x>5e6) return printf("-1\n"),0; Pre(x); for (int i=1;i<=n;i++) if (a[i]<=x) tag[a[i]]=1; int cnt=0; for (int i=1;i<=num && prime[i]<x;i++) if (!tag[prime[i]]) return printf("-1\n"),0; else cnt++; printf("%d\n",cnt); return 0;}
0 0
- [乱搞] Codeforces 73E Beta Round #66 E. Morrowindows
- CodeForces 73 E.Morrowindows(数论)
- Codeforces Beta Round #5 E
- Codeforces Beta Round #8 E. Beads
- Codeforces Beta Round #5 E. Bindian Signalizing
- Codeforces Beta Round #49 (Div. 2) E
- Codeforces Beta Round #8 E. Beads
- Codeforces 463 E 乱搞
- Codeforces Round #346 (Div. 2)E. New Reform 乱搞dfs
- 【Codeforces Beta Round #19】Codeforces 19E Fairy
- 【Codeforces Beta Round #36】Codeforces 36E Two Paths
- 【Codeforces Beta Round #37】Codeforces 37E Trial for Chief
- 【Codeforces Beta Round #26 】Codeforces 26E Multithreading
- Codeforces Beta Round #63 (Div. 2) E题
- Codeforces Beta Round #69 (Div. 2 Only) E题
- Codeforces Beta Round #95 (Div. 2) A B C E
- Codeforces Beta Round #22 (Div. 2 Only) E. Scheme
- Codeforces Beta Round #46 (Div. 2) E. Common ancestor
- 最大公约数算法
- MyBatis 源码分析——生成Statement接口实例
- Weex入门教程之10,vue-router 路由
- java 异常被catch后 将会继续执行
- 树-A- 二叉数应用
- [乱搞] Codeforces 73E Beta Round #66 E. Morrowindows
- 【Python】学习笔记——-8.5、面向对象高级编程:5.使用枚举类
- Linux学习之:磁盘分区
- 树-234树
- SpringMVC入门之七:使用JSP作为视图
- Android守护进程
- 【Python】学习笔记——-8.6、面向对象高级编程:6.使用元类
- CocoaPods pod install/pod update更新慢的问题
- controllers间通信-delegate、Notification、KVO比较