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. 洛谷 P5424 [USACO19OPEN]Snakes

    题目链接 题目描述 传说,数千年前圣帕特里克消灭了哞尔兰所有的蛇.然而,蛇们现在卷土重来了!圣帕特里克节是在每年的3月17日,所以Bessie要用彻底清除哞尔兰所有的蛇来纪念圣帕特里克. Bessie ...

  2. latex一些有用的写法

    编辑博文的时候总是忘语法,然后到网上查-- 干脆记一下! 1.编辑漂亮的函数上下标 \(\sum\limits_{i=1}^n\) 对于原有的函数:$\sum\limits_{i=1}^n$ \(\m ...

  3. git hub安装

    windows下GitHub的安装.配置以及项目的上传过程详细介绍 阅读目录 概要 操作必备 GitHub的安装 Git的初始配置 本地Git与远程GitHub连接的建立 将本地项目上传到GitHub ...

  4. 浅谈openresty

    浅谈openresty 为什么会有OpenResty? 我们都知道Nginx有很多的特性和好处,但是在Nginx上开发成了一个难题,Nginx模块需要用C开发,而且必须符合一系列复杂的规则,最重要的用 ...

  5. .net core 认证与授权(一)

    前言 .net core web并不是一个非常新的架构,很多文章提及到认证与授权这个过程,但是一般都会提及到里面的方法怎么用的,而不是模拟一个怎样的过程,所以我打算记录自己的理解. 什么是认证?我们大 ...

  6. qt creator源码全方面分析(2-1)

    目录 coding-style.html 提交代码 二进制兼容性和源代码兼容性 代码构造 格式化 利用标识符 空格 大括号 圆括号 换行符 声明 命名空间 模式与实践 命名空间 传递文件名 插件扩展点 ...

  7. vscode 调试 react 项目

    主要分为以下三个步骤 安装 debug for chrome 配置 launch.json 文件 配置内容如下 { "version": "0.2.0", &q ...

  8. React 函数生命周期

      React 函数生命周期基础 1 ,概念 在组件创建.到加载到页面上运行.以及组件被销毁的过程中,总是伴随着各种各样的事件,这些在组件特定时期,触发的事件,统称为组件的生命周期:* 2,组件生命周 ...

  9. python笔记15

    今日内容 模块知识 内置模块 time datetime json 其他 内容回顾 & 作业题 重要知识点 构造字典和函数对应关系,避免重复的if else a=1 b=2 ==> a, ...

  10. SASS用法入门

    本文参考了 阮一峰 老师对 SASS 用法的讲解. 学过 CSS 的人都知道,它不是一种编程语言,在日常的开发中,经常要写大量的 css 代码,有很多的重复代码,效率很低.Sass 是一个 CSS 的 ...