LightOj 1163 - Bank Robbery(x-x/10 = n求所有的 x )
题目链接: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 )的更多相关文章
- 1163 - Bank Robbery
1163 - Bank Robbery In one very cold morning, Mark decides to rob a bank. But while trying hacking ...
- 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 ...
- 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得到 ...
- Bank Robbery LightOJ - 1163(推方程 注意计算机的计算方式)
题意:一个数A,如果A去掉它的最后一位就变成了B,即B=A/10,给A - B,求A #include <iostream> #include <cstdio> #includ ...
- 【codeforces 794A】Bank Robbery
[题目链接]:http://codeforces.com/contest/794/problem/A [题意] 每个位置上可能有物品(>=1)或是没物品 你一开始在某一个位置b; 然后你最左可以 ...
- LightOj 1197 - Help Hanzo(分段筛选法 求区间素数个数)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1197 题意:给你两个数 a b,求区间 [a, b]内素数的个数, a and b ( ...
- lightoj 1300 边双联通分量+交叉染色求奇圈
题目链接:http://lightoj.com/volume_showproblem.php?problem=1300 边双连通分量首先dfs找出桥并标记,然后dfs交叉着色找奇圈上的点.这题只要求在 ...
- x的x次幂的值为10,求x的近似值
public class Main { static double eps = 1e-7; public static void main(String[] args){ double l = 2,r ...
- 华为机试题【10】-求数字基root
题目描述: 求整数的Root:给定正整数,求每位数字之和;如果和不是一位数,则重复; 输入:输入任意一个或多个整数 输出:输出各位数字之和,直到和为个位数为止(输入异常,则返回-1),多行,每行对应一 ...
随机推荐
- 【BZOJ】2321: [BeiJing2011集训]星器(数学+特殊的技巧)
http://www.lydsy.com/JudgeOnline/problem.php?id=2321 完全想不到.. 第一眼以为是爆搜,看到数据范围果断放弃:第二眼以为是网络流(因为只有行列操作, ...
- BZOJ3676 [Apio2014]回文串
Description 考虑一个只包含小写拉丁字母的字符串s.我们定义s的一个子串t的“出 现值”为t在s中的出现次数乘以t的长度.请你求出s的所有回文子串中的最 大出现值. Input 输入只有一行 ...
- JAVA_RSA密钥生成
在网上找了下RSA的密钥的创建,结果全是用java序列化PublicKey和PrivateKey来保存,就自己写了个RSA公钥和私钥的创建,及进行Base64编码后保存. 这里用到了 bcprov-j ...
- linux系统tomcat启动正常访问不到主页面
环境: linux系统 tomcat 6.0.24 jdk 1.6 防火墙的问题: 查看防火墙命令:chkconfig --list | grep -i iptables 关闭防火墙命令:/sbin/ ...
- SSh结合Easyui实现Datagrid的分页显示
近日学习Easyui,发现非常好用,界面很美观.将学习的心得在此写下,这篇博客写SSh结合Easyui实现Datagrid的分页显示,其他的例如添加.修改.删除.批量删除等功能将在后面的博客一一写来. ...
- replaceCharactersInRange
NSString 替换字符串中某一位置的文字 replaceCharactersInRange NSString 替换字符串中某一位置的文字 - (void)viewDidLoad { NSMuta ...
- System.getProperty
我们可以通过System.getProperty("user.home")读取JAVA系统的user.home属性的值.
- linux load average
性能分析_linux服务器CPU_Load Average 理解Linux系统中的load average(图文版) 理解Load Average做好压力测试 top命令的Load average 含 ...
- [听课笔记]Professor Michael Cusumano's New Book:" Strategy Rules: Five Timeless Lessons from Bill Gates, Andy Grove, and Steve Jobs"
1. Look Forward, Reason Back Extrapolate, interpret, then tie vision to concrete actions2. Make Big ...
- NVPerfHUD
http://www.cnblogs.com/cproom/archive/2006/11/13/559287.html NVPerfHUD是一个很好的3D程序调试工具,它是NVPerfKit的一部分 ...