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> ...
随机推荐
- Apple 企业开发者账号申请记录
1.账号分类 Apple开发者账号分三种,个人,公司,还有企业.个人和公司都称为标准账号. 还有一种是教育机构的账号. 记录:申请日期2013年4月26,看申请周期多长. 个人和公司的就不说了,现在只 ...
- jQuery改变CSS使DIV显示
HTML: <div id="mazey" style="display:none;">www.mazey.net</div> jQue ...
- HashMap 扩容机制
引用于: http://www.cnblogs.com/hongdada/p/6024832.html HashMap: public HashMap(int initialCapacity, flo ...
- 使用nose_parameterized使unitTest实现参数化
nose-parameterized是一个针对Python单元测试框架实现参数化的扩展 import unittest # from nose_parameterized import paramet ...
- Retrofit2.2说明-简单使用
很久前就想学习下Retrofit了,不过总是没有时间,正好最近新项目要用到网络请求,正好研究了下Retrofit2.2的简单使用方法,大致记录如下: Retrofit与okhttp共同出自于Squar ...
- MFC中修改程序图标
在使用MFC时,我们经常需要修改我们得到的exe文件的图标.如:写一个随机画圆的小程序,我们就希望该程序的图标是个圆或者是和圆有关的图标.所以,在这里我就记录一下我修改图标的步骤. 顺便提一下,我使用 ...
- ACM解题之素矩阵
题意: 如果一个矩形的两条边都是素数,则称此矩形为素矩形.本题给出一个素矩形的面积,请计算其两条边的值.有多个测试用例.每个用例占一行,包含一个表示素矩形面积且不超过 108 的正整数.输入直至没有数 ...
- Spring笔记:事务管理
Spring笔记:事务管理 事务管理 Spring事务管理是通过SpringAOP去实现的.默认情况下Spring在执行方法抛出异常后,引发事务回顾,当然你可以用拦截器或者配置去改变它们. 这部门内容 ...
- 17 南宁区域赛 F - The Chosen One 【规律】
题目链接 https://nanti.jisuanke.com/t/19972 题意 给出一个n 然后将 n 个数 标号为 1 -> n 按顺序排列 每次抽掉 奇数位的数 然后求最后剩下那个数字 ...
- PAT 天梯赛 L1-006. 连续因子 【循环】
题目链接 https://www.patest.cn/contests/gplt/L1-006 思路 输出的连续因子 的乘积 也要是这个数的因子 就每个数先找它的单因子 然后每个单因子往上一个一个遍历 ...