1163 - Bank Robbery
 

In one very cold morning, Mark decides to rob a bank. But while trying hacking into the security system, he found that it is locked by some random value. He also found a pattern on the random number, that is if he chops off the last digit of a number A, he gets a new number B. Then he calculates (A-B). He checked the first few numbers of the security system which exactly equals (A-B). Being very excited to have found the pattern, he learns that there are like 500 levels on the security system. He calculated all those numbers by hand but took a lot of time. As a sign of his accomplishment he left a note on the vault stating the pattern. You were the first officer on the crime scene and you've obtained the note. So if you can figure out A from (A-B), you can rob the bank very quick!

By the way, Mark succeeded in robbing the bank but had a heart attack on the getaway car and crashed.

Input

Input starts with an integer T (≤ 500), denoting the number of test cases.

Each line contains a single positive integer between 10 and 1018 (inclusive), giving the value of A-B.

Output

For each case, print the case number and the possible values of A in ascending order. Separate consecutive numbers with a single space.

Sample Input

Output for Sample Input

4

31

18

12

17

Case 1: 34

Case 2: 19 20

Case 3: 13

Case 4: 18

题意:给出A-B,求A, B为A去掉最后一位形成的数。

分析:B = A / 10, 设A的最后一位为x, A-B的值为n(已知), B * 10 + x - B = n, 即9 * B = n - x; 而 x的取值为0 到9. A = (n - x)* 10 / 9 + x。

代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
typedef unsigned long long ll;///注意是无符号位长整型,有符号位长整型会溢出。
#define N 100
using namespace std;
ll n;

int main()
{
int T, cas;
ll a[N];

scanf("%d", &T);

cas = 0;

while(T--)
{
cas++;
memset(a, 0, sizeof(a));

scanf("%llu", &n);

int k = 0;
for(int i = 0; i <= 9; i++)
{
if((n - i) % 9 == 0)
a[k++] =(n-i)*10/9 + i;
}
sort(a, a+k);///输出要求按升序排列。

k = unique(a, a+k) - a;///类属性算法unique的作用是从输入序列中“删除”所有相邻的重复元素。
printf("Case %d:", cas);
for(int i = 0; i < k; i++)
printf(" %llu", a[i]);

printf("\n");

}
return 0;
}

1163 - Bank Robbery的更多相关文章

  1. LightOj 1163 - Bank Robbery(x-x/10 = n求所有的 x )

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1163 题意:有一个数A,然后去掉A的最后一位得到B,先告诉你A-B的值,求所有满足条件 ...

  2. Codeforces Round #414 A. Bank Robbery

    A. Bank Robbery time limit per test 2 seconds memory limit per test   256 megabytes   A robber has a ...

  3. Bank Robbery LightOJ - 1163(推方程 注意计算机的计算方式)

    题意:一个数A,如果A去掉它的最后一位就变成了B,即B=A/10,给A - B,求A #include <iostream> #include <cstdio> #includ ...

  4. 【codeforces 794A】Bank Robbery

    [题目链接]:http://codeforces.com/contest/794/problem/A [题意] 每个位置上可能有物品(>=1)或是没物品 你一开始在某一个位置b; 然后你最左可以 ...

  5. Hdu 2955 Robberies 0/1背包

    Robberies Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  6. DP专题训练之HDU 2955 Robberies

    打算专题训练下DP,做一道帖一道吧~~现在的代码风格完全变了~~大概是懒了.所以.将就着看吧~哈哈 Description The aspiring Roy the Robber has seen a ...

  7. HDU2955 Robberies[01背包]

    Robberies Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  8. HDU 2955(0-1背包问题)

    题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87125#problem/M 题目: Description The aspir ...

  9. HDU2955 背包DP

    Robberies Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

随机推荐

  1. spark和strom优劣分析

    对于Storm来说:1.建议在那种需要纯实时,不能忍受1秒以上延迟的场景下使用,比如实时金融系统,要求纯实时进行金融交易和分析2.此外,如果对于实时计算的功能中,要求可靠的事务机制和可靠性机制,即数据 ...

  2. Java框架之SpringMVC 03-RequestMapping-请求数据-响应数据

    SpringMVC SpringMVC是一种轻量级的.基于MVC的Web层应用框架. 通过一套 MVC 注解,让 POJO 成为处理请求的控制器,而无须实现任何接口. 采用了松散耦合可插拔组件结构,比 ...

  3. LeetCode 第98题--验证二叉搜索树

    1. 题目 2.题目分析与思路 3.代码 1. 题目 给定一个二叉树,判断其是否是一个有效的二叉搜索树. 假设一个二叉搜索树具有如下特征: 节点的左子树只包含小于当前节点的数.节点的右子树只包含大于当 ...

  4. Mysql.复选条件的查询

    场景:有筛选条件 联盟:1.复联 2.正义联盟 3.猛禽小队,条件可多选,求查询结果. name league 飞人 复联,正义联盟 黑人 复联,正义联盟,猛禽小队 打手枪的男人 复联,猛禽小队 深井 ...

  5. python类型-序列-元组

    元组是一种不可变类型,元组可用作一个字典的key. 1.创建一个元组并进行赋值 atuple = (123, 'abc', ('inner', 'tuple'), 7-9j) 2.访问元组中的值 元组 ...

  6. springboot中的那些连接池

    hello~各位读者新年好! 回想起前几天在部署springboot项目到正线时,线上环境要求jdk7,可项目是基于jdk8开发的,springboot也是用的springboot2以上的版本,可以说 ...

  7. Python脚本通过ftp协议移植文件

    需求 项目需要定时移植多个客户服务器的文件到公司服务器上,确保文件定时同步和生成监控日志 机制原理 1.客户和公司服务器同时安装vpn,绕过复杂的网关,linux下使用的OpenVPN 2.服务器定时 ...

  8. Jutil 单元测试

    eclipse 自身集成了jtuil,右击项目,点击bulidpath,addjar,如下所示添加jutil 新建一个Junit的测试类用来测试上面的测试方法,新增Junit的测试类方法如下: // ...

  9. C++ 类模板详解(一):概念和基本使用方式

    与函数模板类似地(C++函数模板详解(一):概念和特性) ,类也可以被一种或多种类型参数化.例如,容器类就是一个具有这种特性的典型例子,它通常被用于管理某种特定类型的元素.只要使用类模板,我们就可以实 ...

  10. 《快乐编程大本营》java语言训练班 3课:java的运算符

    第1节. 算术运算符 第2节. 递增和递减运算符 第3节. 比较运算符 第4节. 逻辑运算符 第5节. 运算符优先级 第6节. 字符串运算 http://code6g.com/pxphp/px/ban ...