B. Sherlock and his girlfriend
来源:互联网 发布:服务器端口检测 编辑:程序博客网 时间:2024/05/18 22:40
解题说明:由于数列连续,故只需要两种颜色,质数一种,素数一种。
#include<cstdio>#include<algorithm>#include<cstring>#include<cstdlib>#include<iostream>#include<cmath>using namespace std;int prime(int x){int i,f=0;for(i=2;i<=sqrt(x);i++){if(x%i==0){return 0;}}return 1;}int main(){ long n,i; int y; scanf("%ld",&n); if(n>2) {y=2;}else {y=1;}printf("%d\n",y); for(i=2;i<=n+1;i++) {if(prime(i)) {printf("1 ");}else {printf("2 ");}} return 0;}
0 0
- B. Sherlock and his girlfriend
- B. Sherlock and his girlfriend
- B. Sherlock and his girlfriend
- 【codeforces 776B】Sherlock and his girlfriend
- Codeforces 776B-Sherlock and his girlfriend
- CodeForces 776B Sherlock and his girlfriend
- Sherlock and his girlfriend (Codeforces-776B)
- Sherlock and his girlfriend
- Sherlock and his girlfriend
- 【CodeForces 776B】 Sherlock and his girlfriend (求素数)
- Codeforces Round #400 B.Sherlock and his girlfriend
- Codeforces Round #400 (Div. 1 + Div. 2, combined)B.Sherlock and his girlfriend【预处理素数+思维】
- Codeforces Round #400 (Div. 1 + Div. 2, combined) 776B Sherlock and his girlfriend
- Codeforces Round #400 (Div. 1 + Div. 2, combined) B. Sherlock and his girlfriend 素数筛法+贪心
- Round B APAC Test 2017 Problem A. Sherlock and Parentheses
- B. Drazil and His Happy Friends
- 515B. Drazil and His Happy Friends
- B. Drazil and His Happy Friends
- poj 2186 (求一个图中可以到达所有点的点的个数) (强连通)
- Servlet 、Filter 的url-pattern
- 蓝桥 字符串比较
- HashMap 和HashTable的区别
- 一些知识点:Spring AOP
- B. Sherlock and his girlfriend
- 什么是IaaS, PaaS和SaaS及其区别
- JS必须保证第一个为数字而不是. 只能輸入4个小数
- rand()函数的分析和使用
- 安卓与js互调
- [BZOJ3771]Triple(FFT+生成函数)
- Android启动模式
- Python HTTP库requests 介绍
- Remove Element (java版)