OpenJ_POJ C16D Extracurricular Sports 打表找规律
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 打表找规律的更多相关文章
- OpenJ_POJ C16B Robot Game 打表找规律
Robot Game 题目连接: http://acm.hust.edu.cn/vjudge/contest/122701#problem/B Description Sgeoghy has addi ...
- hdu 3032 Nim or not Nim? (SG函数博弈+打表找规律)
Nim or not Nim? Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Sub ...
- HDU 5753 Permutation Bo (推导 or 打表找规律)
Permutation Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...
- HDU 4861 Couple doubi (数论 or 打表找规律)
Couple doubi 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/D Description DouBiXp has a ...
- 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 ...
- 【ZOJ】3785 What day is that day? ——浅谈KMP在ACM竞赛中的暴力打表找规律中的应用
转载请声明出处:http://www.cnblogs.com/kevince/p/3887827.html ——By Kevince 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这 ...
- HDU 5795 A Simple Nim(SG打表找规律)
SG打表找规律 HDU 5795 题目连接 #include<iostream> #include<cstdio> #include<cmath> #include ...
- hdu_5894_hannnnah_j’s Biological Test(打表找规律)
题目链接:hdu_5894_hannnnah_j’s Biological Test 题意: 有n个不同的位置围成一个圈,现在要安排m个人坐,每个人至少的间隔为k,问有多少种安排 题解: 先打表找规律 ...
- hdu_5795_A Simple Nim(打表找规律的博弈)
题目链接:hdu_5795_A Simple Nim 题意: 有N堆石子,你可以取每堆的1-m个,也可以将这堆石子分成3堆,问你先手输还是赢 题解: 打表找规律可得: sg[0]=0 当x=8k+7时 ...
随机推荐
- (32位)本体学习程序(ontoEnrich)系统使用说明文档
系统运行:文件夹system下,可执行文件ontoEnrichment --------------------------------------------------------1.简单概念学习 ...
- hibernate的一对多和多对一关联
一对一的关联就不写了,一般项目也用不到,如果可以一对一就直接合成一个表了,也不会出现一对一的关系. 本文主要研究一对多的关系. 1.一对多的关系研究: (1)RDB中关系表达: 多的一方创建外键指向 ...
- SpringMVC_HelloWorld_01
通过配置文件的方式实现一个简单的HelloWorld. 源码 一.新建项目 1.新建动态web项目 2.命名工程springmvc-01 3.勾选"Generate web.xml depl ...
- 网络io模式(服务器请求应答模式)
2014年1月19日 22:07:41 这几天看nginx 和 Apache的视频教程(马哥和邹老师)了解到了一些网络io模式(nginx的相关配置项为sendfile) 这里简单记录下来以备后用 A ...
- python try详细说明(python的异常捕捉模块)
#自己常用 try: pass except Exception as e: print("break for :"+str(e)) # 划重点: 1. 正常执行try情况 pri ...
- 通过anaconda进行python多版本控制
---恢复内容开始--- linux与windows通用. 1. 假设电脑上已经转好anaconda3. (anaconda 默认装好了python3.jupyter.spyter) 2. 现在需求是 ...
- Demo005 小学四则运算自动生成程序
目录 小学四则运算自动生成程序 0.传送门 1.题目要求 2.功能实现 2.1 总体设计 2.2 用户欢迎界面 2.3 用户功能界面 2.4 屏幕输出 2.5 文本输出 2.6 获取时间 2.7 用户 ...
- wpf 如果列表加载超多数据变的卡顿时,使用VirtualizingStackPanel
如果列表加载超多数据变的卡顿时 <ListBox > <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Virt ...
- 【论文阅读】HydraPlus-Net: Attentive Deep Features for Pedestrian Analysis
转载请注明出处:https://www.cnblogs.com/White-xzx/ 原文地址:https://arxiv.org/abs/1709.09930 Github: https://git ...
- mysql 日期操作 增减天数、时间转换、时间戳(转换)
http://hi.baidu.com/juntao_li/item/094d78c6ce1aa060f6c95d0b MySQL datediff(date1,date2):两个日期相减 date1 ...