Robot Game

题目连接:

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

Description

Sgeoghy has addicted herself to an interesting computer game! In this game, she needs to control a robot to pick up a required number of components. There are a lot of components lying in a line with arbitrary intervals, indexed from left to right, starting with 1. No two or more components share the same position. In the beginning, the robot starts at a random position where a component lies, and the robot should pick it up. Then on each step, the player can program the robot, by controlling its moving direction (left or right) as well as moving distance. After each step of moving, if there is a component at the destination, the robot will pick it up; But if not, the robot will die and the game will be over.

Unfortunately, Sgeoghy is poor at programming. She can only make the robot move a fixed distance towards a fixed direction (left or right) every single step. For example, the positions of the components are:

and the robot starts at the position of 5-th component. If Sgeoghy controls the robot to move a fixed distance 2 and a fixed direction right on each step, the robot can pick up 3 components indexed as 5, 6, 8, and dies at Position 15.

At first, Sgeoghy can barely complete the missions. However, since the mission is getting harder and harder, she is getting stuck. Now she is facing a mission that the positions of the components are:

and the robot starts at the position of y-th component. The robot is required to pick up 100 components to complete this mission. Can you help her? Since she can only program the robot to move a fixed distance towards a fixed direction, it may be impossible for her to complete this mission. However, you should still tell her the most components she can get.

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 y (1 ≤ y ≤ 10^100), indicating that the robot starts at the position of y-th component.

Output

For each test case:

The first line contains an integer n, indicating either the maximum possible number of components (1 ≤ n < 100) that the robot can pick up in this mission, or n=100 if Sgeoghy is able to complete this mission.

Then follows n lines, the i-th line contains an integer xi, indicating the index of the i-th component picked up by the robot. Obviously, x1=y and x1,x2,...,xn are sequenced in strictly monotonic order. If there are several solutions, output any one.

Sample Input

1

7661

Sample Output

3

7661

5417

5

Hint

题意

第i个零件的位置是i(i+1)

有个机器人,一开始站在第y个零件的位置,这个机器人只能往前一直走,或者一直往下走,然后每一步的距离也必须相同,且每一步都必须踩到零件上面。

问你这个机器人最多走多少步,且把每一步的零件坐标输出。

题解:

看了下样例,感觉最多走三步。

打表找规律,发现输入x,输出5x+2,和7x+3就好了

猜到结论之后,证明就很简单了,这儿省略。

代码

import java.io.*;
import java.math.*;
import java.util.*; public class Main
{
public static void main(String argv[]) throws Exception
{
Scanner cin = new Scanner(System.in);
int T = cin.nextInt();
for( int cas = 1 ; cas <= T ; ++ cas ){
BigInteger index = cin.nextBigInteger();
System.out.println("3");
System.out.println( index );
System.out.println( index.multiply(BigInteger.valueOf(5)).add(BigInteger.valueOf(2)) );
System.out.println( index.multiply(BigInteger.valueOf(7)).add(BigInteger.valueOf(3)) );
}
}
}

OpenJ_POJ C16B Robot Game 打表找规律的更多相关文章

  1. OpenJ_POJ C16D Extracurricular Sports 打表找规律

    Extracurricular Sports 题目连接: http://acm.hust.edu.cn/vjudge/contest/122701#problem/D Description As w ...

  2. Codeforces Beta Round #24 D. Broken robot (打表找规律)

    题目链接: 点击我打开链接 题目大意: 给你 \(n,j\),再给出 \(m[0]\) 的坐标和\(a[0]-a[n-1]\) 的坐标. 让你输出 \(m[j]\) 的坐标,其中 \(m[i]\) 和 ...

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

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

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

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

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

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

  6. 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 ...

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

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

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

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

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

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

随机推荐

  1. Codeforces Round #477 (rated, Div. 2, based on VK Cup 2018 Round 3) F 构造

    http://codeforces.com/contest/967/problem/F 题目大意: 有n个点,n*(n-1)/2条边的无向图,其中有m条路目前开启(即能走),剩下的都是关闭状态 定义: ...

  2. django2.0 官方中文文档地址

    django2.0 官方开始发布中文文档了,之前还想着一直翻译完成所有有必要的内容,想着可以省事一些了,打开以后看了一下,发现官方的中文文档还没翻译完成, 现在(2018-7-10)最新章节是是  编 ...

  3. ZYNQ. DMA基本用法

    DMA环路测试 vivadoblock zynq7 + dma +fifo sdk 中可以导入 demo demo 中 默认都是 一个字节8bit数据 的测试程序. 如果是其他长度的数据,不仅要修改数 ...

  4. SVM Kernel Functions

    ==================================================================== This article came from here. Th ...

  5. 使用Sysmon和Splunk探测网络环境中横向渗透

    当前很难在网络中探测攻击者横向渗透,其中原因有很难获取必要的日志和区别正常与恶意行为.本篇文章介绍通过部署Sysmon并将日志发送到SIEM来探测横向渗透. 工具: Sysmon + Splunk l ...

  6. python3之模块io使用流的核心工具

    1.io概叙 io模块提供了python用于处理各种类型I/O的主要工具,主要有三种类型的I/O:文本I/O,二进制I/O和原始I/O:这些都是通用类型,各种后备存储可使用其中的每一种类型,所以这些类 ...

  7. 002_tmux详解

    参考下赖老师的: http://mingxinglai.com/cn/2012/09/tmux/ 一. 二. http://wdxtub.com/2016/03/30/tmux-guide/   (待 ...

  8. activiti流程跟踪图算法

    流程跟踪图-推导算法 工作中使用activiti实现流程图相关业务,但是上线后遇到问题,偶尔流程图出不来.查阅了一下画流程图的实现,基本上是参见:activiti-流程图颜色变化之一篇. 核心类,参见 ...

  9. 驱动程序vmci.sys版本不正确。请尝试重新安装 VMware

    今天在测试一台服务器,安装在虚拟机里面,但是发现在安装后,重启了一下电脑,出现了这个错误: 无法获取 vmci 驱动程序版本: 句柄无效.驱动程序 vmci.sys 版本不正确.请尝试重新安装 VMw ...

  10. shell升级

    对/sbin/nologin的理解   系统账号的shell使用 /sbin/nologin ,此时无法登陆系统,即使给了密码也不行.   所谓“无法登陆”指的仅是这个用户无法使用bash或其他she ...