题目链接:http://lightoj.com/volume_showproblem.php?problem=1163

题意:有一个数A,然后去掉A的最后一位得到B,先告诉你A-B的值,求所有满足条件的A,按从小到大的顺序输出;

其实就是x-x/10=n求所有的 x(这里的x/10是取整)

还可以写成是:num*10+r - num = n,其中num*10+r = A, n = B, r是A的个位数字;r一定是0-9中的一个数,可以枚举,所以可以得到 9 * num = n-r;

所以只要找到所有的r是的(n-r)%9 == 0即可;

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
typedef unsigned long long LL;
#define N 1000001
using namespace std;
const double eps = 1e-; int main()
{
int T, t = ;
scanf("%d", &T);
while(T --)
{
LL n;
scanf("%llu", &n);
LL ans[] = {};
int k = ;
for(int i=; i<=; i++)
{
if((n-i)% == )
ans[k++] = (n-i)/*+i;
}
sort(ans, ans+k);
k = unique(ans, ans+k) - ans;
printf("Case %d:", t++);
for(int i=; i<k; i++)
printf(" %llu", ans[i]);
printf("\n");
}
return ;
}

LightOj 1163 - Bank Robbery(x-x/10 = n求所有的 x )的更多相关文章

  1. 1163 - Bank Robbery

    1163 - Bank Robbery   In one very cold morning, Mark decides to rob a bank. But while trying hacking ...

  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. C# 求余 int a = 371 / 100 % 10,求a的结果为多少?//nt 和int类型计算得到的结果还是int类型

    //int 和int类型计算得到的结果还是int类型 eg:int a = 371 / 100 % 10,求a的结果为多少? 首先371除以100,再让此结果除以10求余数. 一 371除以100得到 ...

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

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

  5. 【codeforces 794A】Bank Robbery

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

  6. LightOj 1197 - Help Hanzo(分段筛选法 求区间素数个数)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1197 题意:给你两个数 a b,求区间 [a, b]内素数的个数, a and b ( ...

  7. lightoj 1300 边双联通分量+交叉染色求奇圈

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1300 边双连通分量首先dfs找出桥并标记,然后dfs交叉着色找奇圈上的点.这题只要求在 ...

  8. x的x次幂的值为10,求x的近似值

    public class Main { static double eps = 1e-7; public static void main(String[] args){ double l = 2,r ...

  9. 华为机试题【10】-求数字基root

    题目描述: 求整数的Root:给定正整数,求每位数字之和;如果和不是一位数,则重复; 输入:输入任意一个或多个整数 输出:输出各位数字之和,直到和为个位数为止(输入异常,则返回-1),多行,每行对应一 ...

随机推荐

  1. svg―Raphael.js Library

    Raphael是一个用于在网页中绘制矢量图形的Javascript库,它使用SVG W3C推荐标准和VML作为创建图形的基础,可以通过JavaScript操作DOM来轻松创建出各种复杂的柱状图.饼图. ...

  2. C#创建桌面快捷方式 和 开机启动

              /// <summary>         /// 创建桌面快捷方式 2010-11-25         /// </summary>         p ...

  3. 【BZOJ】1251: 序列终结者(splay)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1251 不行..为什么写个splay老是犯逗,这次又是null的mx没有赋值-maxlongint.. ...

  4. HttpClient工具类v1.7

    package com.cucpay.fundswap.util; import java.io.IOException; import java.net.SocketTimeoutException ...

  5. 用 Freemarker 生成 word 文档(包含图片)

    1. 用word写一个需要导出的word模板,然后存为xml格式. 2. 将xml中需要动态修改内容的地方,换成freemarker的标识符,例如: <w:p wsp:rsidR="0 ...

  6. HP StorageWorks MSL2024 Tape Libraries - Tape library Error Codes

    Main error codes Error Code Description Details and Solution 80 Can not initialize bar code reader P ...

  7. PISCES P4-vSwitch 安装以及一次失败的测试

    本文参考 (1)Varant Download:点我 (2)Mac上安装Git:戳我 (3)Github P4-vSwitch/Varant:点我 (4)Mac强制重新启动:戳我 实验环境: Mac ...

  8. Rails--bundle exec rake db:migrate

    --新建表: def up create_table :[TABLE_NAME] do |t| t.column :[NUM], :integer t.column :[NAME], :string ...

  9. 五一结束,北戴河,yy,差一点,不太敢

    collectionView Cell 设置颜色,蓝色,但是其他cell颜色也蓝色了,因为只写了if 没写else if (indexPath.item == 0) { cell.background ...

  10. Environment Variables

    https://msdn.microsoft.com/en-us/library/windows/desktop/ms682653(v=vs.85).aspx Every process has an ...