Extracurricular Sports

题目连接:

http://acm.hust.edu.cn/vjudge/contest/122701#problem/D

Description

As we all know, to pass PE exams, students need to do extracurricular sports, especially jogging. As the result, the Jogging Association in the university is very popular.

There are N students in the Jogging Association. Some run faster while the others run slower. The time it takes for a student to run exactly one lap is called his/her ''lap time'', which is always a positive integer. The lap times of students are distinct from each other. However, running too slow is not allowed for students of the Jogging Association, so each lap time is at most 100 digits.

One day, they make an appointment to jog together. They begin at the same time as well as the same starting point, jog along the circular runway at their own steady speed round and round, not stop until the first time when all of them meet again at the starting point. When they stop, they accidently find that the time they have spent is precisely equal to the time they need if everyone runs a lap one by one, as a relay race.

Now we are curious about the lap times of all the students. Can you guess out any possible solution?

Input

The first line contains an integer T (1 ≤ T ≤ 30), indicating the number of test cases.

For each test case:

A line contains an integer N (2 ≤ N ≤ 200), indicating the number of students.

Output

For each test case:

If the solution does not exist, output -1 on a single line;

Otherwise, output one solution with n different integers t1,t2,...,tn, one per line, where ti (1 ≤ ti < 10^100) indicates the lap time of the i-th student. If there are several solutions, output any one.

Sample Input

1

3

Sample Output

10

20

30

Hint

题意

让你构造出n个不同的数,使得这n个数的lcm等于这n个数的和

题解:

还是打表找规律

发现就是 1 2 3 -> 1 2 6 9 -> 1 2 6 18 27 -> 1 2 6 18 54 81 .....这样就行了

代码

import java.io.*;
import java.math.*;
import java.util.*; public class Main
{
static BigInteger ans[][] = new BigInteger[250][250];
public static void main(String argv[]) throws Exception
{
Scanner cin = new Scanner(System.in);
ans[3][1] = BigInteger.valueOf(1) ;
ans[3][2] = BigInteger.valueOf(2) ;
ans[3][3] = BigInteger.valueOf( 3 );
for(int i = 3 ; i <= 200 ; ++ i){
for(int j = 1 ; j <= i - 1 ; ++ j) ans[i + 1][j] = ans[i][j];
ans[i + 1][i] = ans[i][i].multiply(BigInteger.valueOf(2));
BigInteger sum = BigInteger.ZERO;
for(int j = 1 ; j <= i ; ++ j) sum = sum.add( ans[i + 1][j] );
ans[i + 1][i + 1] = sum;
}
int T = cin.nextInt();
for(int cas = 1 ; cas <= T ; ++ cas ){
int N = cin.nextInt();
if( N == 2 ) System.out.println( -1 );
else{
for(int j = 1 ; j <= N ; ++ j) System.out.println( ans[N][j] );
}
}
}
}

OpenJ_POJ C16D Extracurricular Sports 打表找规律的更多相关文章

  1. OpenJ_POJ C16B Robot Game 打表找规律

    Robot Game 题目连接: http://acm.hust.edu.cn/vjudge/contest/122701#problem/B Description Sgeoghy has addi ...

  2. hdu 3032 Nim or not Nim? (SG函数博弈+打表找规律)

    Nim or not Nim? Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Sub ...

  3. HDU 5753 Permutation Bo (推导 or 打表找规律)

    Permutation Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...

  4. HDU 4861 Couple doubi (数论 or 打表找规律)

    Couple doubi 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/D Description DouBiXp has a ...

  5. HDU2149-Good Luck in CET-4 Everybody!(博弈,打表找规律)

    Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  6. 【ZOJ】3785 What day is that day? ——浅谈KMP在ACM竞赛中的暴力打表找规律中的应用

    转载请声明出处:http://www.cnblogs.com/kevince/p/3887827.html    ——By Kevince 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这 ...

  7. HDU 5795 A Simple Nim(SG打表找规律)

    SG打表找规律 HDU 5795 题目连接 #include<iostream> #include<cstdio> #include<cmath> #include ...

  8. hdu_5894_hannnnah_j’s Biological Test(打表找规律)

    题目链接:hdu_5894_hannnnah_j’s Biological Test 题意: 有n个不同的位置围成一个圈,现在要安排m个人坐,每个人至少的间隔为k,问有多少种安排 题解: 先打表找规律 ...

  9. hdu_5795_A Simple Nim(打表找规律的博弈)

    题目链接:hdu_5795_A Simple Nim 题意: 有N堆石子,你可以取每堆的1-m个,也可以将这堆石子分成3堆,问你先手输还是赢 题解: 打表找规律可得: sg[0]=0 当x=8k+7时 ...

随机推荐

  1. bzoj千题计划226:bzoj2763: [JLOI2011]飞行路线

    http://www.lydsy.com/JudgeOnline/problem.php?id=2763 这也算分层图最短路? dp[i][j]到城市i,还剩k次免费次数的最短路 #include&l ...

  2. bzoj千题计划193:bzoj2460: [BeiJing2011]元素

    http://www.lydsy.com/JudgeOnline/problem.php?id=2460 按魔力值从小到大排序构造线性基 #include<cstdio> #include ...

  3. 封装JSON数据转自定义HTML方法parseHTML

    开发过程中经常使用字符串拼接,这样做工作效率低,可维护性和易读性也比较差,且对于后台程序员对html不熟悉,经常出错. 如下面例子json转字符串: var json = [{ href:'http: ...

  4. Angular 下的 directive (part 1)

    directive  指令 Directive components  指令部分   使用指令自动引导一个AngularJS应用.ngApp指令指定应用程序的根元素,通常是放在页面的根元素如: < ...

  5. [python]python错误集锦

    ValueError: invalid literal : ''不能将非数字字符串转换为整型 object has no attribute 对象调用一个没有的方法(内建或自定义) TypeError ...

  6. 20155220 2016-2017-2 《Java程序设计》第六周学习总结

    20155220 2016-2017-2 <Java程序设计>第六周学习总结 教材学习内容总结 第十章 输入输出 10.1 InputStream OutputStream 数据有来源与目 ...

  7. Zookeeper笔记之命令行操作

    $ZOOKEEPER_HOME/bin下的zkCli.sh进入命令行界面,使用help可查看支持的所有命令: 一.节点相关操作 create [-s] [-e] path data acl creat ...

  8. Unity3d 常用代码

    //创建一个名为"Player"的游戏物体 //并给他添加刚体和立方体碰撞器. player=new GameObject("Player"); player. ...

  9. python 入门基础23 选课系统 项目

    选课系统 代码地址:github_code # 选课系统 # 角色:学校.学员.课程.讲师 # 要求: # 1. 创建北京.上海 2 所学校 # 2. 创建linux , python , go 3个 ...

  10. 春夏秋冬又一春之Redis持久化

    历史文章推荐: 一只准程序猿的唠叨 可能是最漂亮的Spring事务管理详解 Java多线程学习(八)线程池与Executor 框架 面试中关于Redis的问题看这篇就够了 非常感谢<redis实 ...