Codeforces Beta Round #61 (Div. 2) D. Petya and His Friends 想法
2 seconds
256 megabytes
standard input
standard output
Little Petya has a birthday soon. Due this wonderful event, Petya's friends decided to give him sweets. The total number of Petya's friends equals to n.
Let us remind you the definition of the greatest common divisor: GCD(a1, ..., ak) = d, where d represents such a maximal positive number that each ai (1 ≤ i ≤ k) is evenly divisible by d. At that, we assume that all ai's are greater than zero.
Knowing that Petya is keen on programming, his friends has agreed beforehand that the 1-st friend gives a1 sweets, the 2-nd one gives a2 sweets, ..., the n-th one gives an sweets. At the same time, for any i and j (1 ≤ i, j ≤ n) they want the GCD(ai, aj) not to be equal to 1. However, they also want the following condition to be satisfied: GCD(a1, a2, ..., an) = 1. One more: all the ai should be distinct.
Help the friends to choose the suitable numbers a1, ..., an.
The first line contains an integer n (2 ≤ n ≤ 50).
If there is no answer, print "-1" without quotes. Otherwise print a set of n distinct positive numbers a1, a2, ..., an. Each line must contain one number. Each number must consist of not more than 100 digits, and must not contain any leading zeros. If there are several solutions to that problem, print any of them.
Do not forget, please, that all of the following conditions must be true:
- For every i and j (1 ≤ i, j ≤ n): GCD(ai, aj) ≠ 1
- GCD(a1, a2, ..., an) = 1
- For every i and j (1 ≤ i, j ≤ n, i ≠ j): ai ≠ aj
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).
3
99
55
11115
4
385
360
792
8360
题意:满足这三个条件,否则输出-1;
- For every i and j (1 ≤ i, j ≤ n): GCD(ai, aj) ≠ 1
- GCD(a1, a2, ..., an) = 1
- For every i and j (1 ≤ i, j ≤ n, i ≠ j): ai ≠ aj
思路:2显然-1;
先找到一个3满足的条件,然后输出一个数的倍数即可;注意不要重复;
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define esp 1e-13
const int N=1e4+,M=1e6+,inf=1e9+,mod=;
int main()
{
int x,y,i,z,t;
scanf("%d",&x);
if(x==)
printf("-1");
else
{
printf("6\n10\n15\n");
for(int i=,t=;i<x-;i++,t++)
printf("%d\n",*t);
}
return ;
}
Codeforces Beta Round #61 (Div. 2) D. Petya and His Friends 想法的更多相关文章
- Codeforces Beta Round #61 (Div. 2)
Codeforces Beta Round #61 (Div. 2) http://codeforces.com/contest/66 A 输入用long double #include<bit ...
- Codeforces Beta Round #57 (Div. 2)
Codeforces Beta Round #57 (Div. 2) http://codeforces.com/contest/61 A #include<bits/stdc++.h> ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
随机推荐
- mysql_数据库_操作
1.查看数据库 show databases; # 默认数据库: test - 用于用户测试数据 information_schema - MySQL本身架构相关数据 2.创建数据库 #utf- 编码 ...
- hdu 4956 Poor Hanamichi BestCoder Round #5(数学题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4956 Poor Hanamichi Time Limit: 2000/1000 MS (Java/Ot ...
- 2、hive的基本操作
1.创建数据库和表 1)创建数据库 hive> CREATE DATABASE IF NOT EXISTS userdb; OK Time taken: 0.252 seconds hive&g ...
- SSH远程登陆docker容器
环境: Ubuntu 16.04(mac osx的VMware Fushion环境) 任务: Ubuntu 16.04通过SSH登陆docker(目的是为了运行在其他服务器的Jenkins访问dock ...
- LeetCode-day03
28. Best Time to Buy and Sell Stock 买卖股票的最好时间 29. Best Time to Buy and Sell Stock II 买卖股票2(多次买入,一次卖出 ...
- django自带的用户认证和form表单功能
一.用户认证 1.用户认证方法 1.ajango自带用户认证功能,只需要引入相应的模块就可以使用,但是前提是必须使用ajango自带的auth_user表,并且需要把用户相关信息存放在该表中. 2.引 ...
- DP专题(不定期更新)
1.UVa 11584 Partitioning by Palindromes(字符串区间dp) 题意:给出一个字符串,划分为若干字串,保证每个字串都是回文串,同时划分数目最小. 思路:dp[i]表示 ...
- Cookie用法简介
java操作Cookie---javax.servlet.http.Cookie 1.增加一个Cookie Cookie cookie = new Cookie("username" ...
- css小技巧1
资料 1. 文本省略 单行省略: white-space:nowrap; overflow:hidden; text-overflow:ellipsis; 多行文本省略: 只兼容webkit内核,不属 ...
- github资源下载速度慢的解决办法
xx-net:https://github.com/XX-net/XX-Net