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. 【PCIE-4】---PCIE中部分概念或问题总结(很基础很重要)

    前面三小节,介绍了PCIE的基本知识和概念,以及扫描流程.在不求甚解的情况下,我想各位小伙伴应该对PCIE有了个宏观的认识,OK,那么本章我们在之前的基础上,再单独把一些概念和更深层次的问题摘出来具体 ...

  2. win10关闭系统更新 (转载)

    一.关闭Windows10系统的自动更新服务 1:使用快捷键Win+R,打开运行 2:输入命令:services.msc,打开系统服务界面 找到Windows Update双击 将启动类型改为[禁用] ...

  3. Pycharm 中的翻译工具

    对于开发来说,大多数哥们英文欠缺,比如在下,我们大多数使用的开发工具是IDEA,IDEA 很强大,开发起来顺手. 废话不多说,让我们看一下如何使用翻译器. 打开Pycharm 的setting 设置, ...

  4. Centos7 搭建Grafana+Jmeter+Influxdb 性能实时监控平台

    未完,待更新 背景 日常工作中,经常会用到Jmeter去压测,毕竟LR还要钱(@¥&*...),而最常用的接口压力测试,我们都是通过聚合报告去查看压测结果的,然鹅聚合报告的真的是丑到家了,作为 ...

  5. Window初始化Git环境

    安装Git 去到官网下载地址,找到自己电脑的对应版本,下载安装就好啦,这里就不一一说明了 https://git-scm.com/download/win 初始化Git环境 第一步:打开git-bas ...

  6. 关于爬虫的日常复习(10)—— 实战:使用selenium模拟浏览器爬取淘宝美食

  7. AFN请求问题

    在使用AFNetworking 2.0  的时候本来一切很顺畅,但是中途遇到几个比较坑的地方 在发送请求后,NSURLSessionDataTask一直报错 Error Domain=com.alam ...

  8. Java入门 - 面向对象 - 06.接口

    原文地址:http://www.work100.net/training/java-interface.html 更多教程:光束云 - 免费课程 接口 序号 文内章节 视频 1 概述 2 接口的声明 ...

  9. CTF中关于XXE(XML外部实体注入)题目两道

    题目:UNCTF-Do you like xml? 链接:http://112.74.37.15:8008/ hint:weak password (弱密码) 1.观察后下载图片拖进WINHEX发现提 ...

  10. Unity SurfaceShader详解

    声明:文章主要是总结手游开发的经验,只涉及到了前向渲染.未涉及延迟渲染. Unity的Surface Shader本质上就是VS/PS.只不过Unity经过精心设计,将shader划分为了几个关键部分 ...