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. vue-cli构建项目使用 less

    在vue-cli中构建的项目是可以使用less的,但是查看package.json可以发现,并没有less相关的插件,所以我们需要自行安装. 第一步:安装 npm install less less- ...

  2. 高品质的JavaScript

    整理书籍内容(QQ:283125476 发布者:M [重在分享,有建议请联系->QQ号]) 养成良好的编程习惯 ##如何避免团队JS冲突 * 避免实用全局变量[可使用匿名函数进行处理]以避免全局 ...

  3. [BZOJ 4350]括号序列再战猪猪侠 题解(区间DP)

    [BZOJ 4350]括号序列再战猪猪侠 Description 括号序列与猪猪侠又大战了起来. 众所周知,括号序列是一个只有(和)组成的序列,我们称一个括号 序列S合法,当且仅当: 1.( )是一个 ...

  4. CF258D Little Elephant and Broken Sorting (带技巧的DP)

    题面 \(solution:\) 这道题主要难在考场上能否想到这个思路(即如何设置状态)(像我这样的蒟蒻就想不到呀QAQ)不过这一题确实很神奇! \(f[i][j]:\)表示第 \(a_i\) 个数比 ...

  5. py-faster-rcnn代码阅读3-roidb.py

    roidb是比较复杂的数据结构,存放了数据集的roi信息.原始的roidb来自数据集,在trian.py的get_training_roidb(imdb)函数进行了水平翻转扩充数量,然后prepare ...

  6. Java基本数据类型装箱的127临界点

    package wrapper.demo; public class WrapperDemo { /** * @param args */ public static void main(String ...

  7. 用Python连接SQLServer抓取分析数据、监控 (pymssql)

    Python 环境:python3 服务器环境: centos6.5 数据库: Mysql 大概流程:在装有Python服务器,利用pymssql库连接MSSQL生产数据库取出数据然后写进mysql数 ...

  8. makefile 中 foreach

    四.foreach 函数 foreach函数和别的函数非常的不一样.因为这个函数是用来做循环用的,Makefile中的foreach函数几乎是仿照于Unix标准Shell(/bin/sh)中的for语 ...

  9. linux终端自定义设置

    2014年1月4日 19:21:16 1. ls命令显示文件列表时不再花花绿绿 vi ~/.bashrc alias ls='ls -a --color=never' alias ll='ls -lh ...

  10. 解决Python3 pip list 红色DEPRECATION

    解决Python3 pip list 红色DEPRECATION 打开文件扩展名和隐藏的项目 找到ProgramData,在该目录下创建pip文件夹,在pip里面创建pip.ini  在pip.ini ...