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),多行,每行对应一 ...
随机推荐
- BZOJ3847 : ZCC loves march
注意到集结操作相当于合并一些点 于是我们可以使用并查集 对于每一行.每一列维护一个链表,储存里面的点 查询x时,在并查集中找到x的祖先u,此时x的坐标就是u的坐标 然后扫描u所在行列的链表,依次删除每 ...
- C#中DataTable使用技巧
在项目中经常用到DataTable,如果DataTable使用得当,不仅能使程序简洁实用,而且能够提高性能,达到事半功倍的效果,现对DataTable的使用技巧进行一下总结. 一.DataTable简 ...
- TYVJ P1004 滑雪 Label:记忆化搜索
背景 成成第一次模拟赛 第三道 描述 trs喜欢滑雪.他来到了一个滑雪场,这个滑雪场是一个矩形,为了简便,我们用r行c列的矩阵来表示每块地形.为了得到更快的速度,滑行的路线必须向下倾斜. ...
- CC150 - 11.5
Question: Given a sorted array of strings which is interspersed with empty strings, write a method t ...
- c语言字符串操作,及常用函数
一,字符串操作 1 . strcpy : 拷贝 char *stpcpy(char *destin, char *source); 2 . strcat : 拼接 char *strcat(char ...
- jQuery 写的幻灯左右切换插件
<html> <head> <meta charset="utf-8"> <title>官网</title> <s ...
- [zt]给你的Mp4大换血,精选Touch里3年收集的900多首歌,"经典不忍去的""最新近流行的",与你共享~~
如果你是音乐爱好者: 这些歌, 请戴上耳机, 调大音量, 一个人听 ,全世界 都是你的!!!!! (一)这些歌很温暖,没有金属味,适合有阳光的午后,很悠闲... [Anaesthesia]Maximi ...
- 又一种Mysql报错注入
from:https://rdot.org/forum/showthread.php?t=3167 原文是俄文,所以只能大概的翻译一下 这个报错注入主要基于Mysql的数据类型溢出(不适用于老版本的M ...
- Leetcode | Palindrome
Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric char ...
- Apache POI使用详解
Apache POI使用详解 1.POI结构与常用类 (1)POI介绍 Apache POI是Apache软件基金会的开源项目,POI提供API给Java程序对Microsoft Office格式档案 ...