HDU 2009 整除的尾数 题解
同组数据的输出。其每一个尾数之间空一格。行末没有空格。
200 40
1992 95
0 0
00 40 80
15
后面两位。目測,推断得最大只是100,那么能够暴力搜索了。
模拟:直接把后面两位的数值接上,然后測试能否够除尽。
#include <stdio.h> int main()
{
int a, b;
while (scanf("%d %d", &a, &b) && (a || b))
{
bool flag = false;
for (int i = 0; i < 10; i++)
{
int t = a * 10 + i;
for (int j = 0; j < 10; j++)
{
int r = t * 10 + j;
if (r % b == 0)
{
if (flag) putchar(' ');
printf("%d%d", i, j);
flag = true;
}
}
}
putchar('\n');
}
return 0;
}
或者直接使用模的特性来做:
#include <stdio.h> int main()
{
int a, b;
while (scanf("%d %d", &a, &b) && b)
{
a = a * 100 % b;
if (a) a = b - a; //须要加上一个数才干整除
printf("%02d", a);
while ((a += b) && a < 100)
{
printf(" %02d", a);
}
putchar('\n');
}
return 0;
}
HDU 2009 整除的尾数 题解的更多相关文章
- hdu 2099 整除的尾数
Problem Description 一个整数,只知道前几位,不知道末二位,被另一个整数除尽了,那么该数的末二位该是什么呢? Input 输入数据有若干组,每组数据包含二个整数a,b(0< ...
- HDU 2099 整除的尾数(枚举 & 暴搜)
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2099 思路分析:这道题的解法可以说是相当暴力了,但也有一些小坑,以下几点萌新们值得留意一下: 1. 仔 ...
- 【水】HDU 2099——整除的尾数
来源:点击打开链接 数据范围小,枚举水过就行了……不过要注意格式! #include <iostream> #include <cstring> #include <io ...
- hdu2099整除的尾数(暴力 省赛)
整除的尾数 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- 整除的尾数[HDU2099]
整除的尾数 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- hdoj 2099 整除的尾数
整除的尾数 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- HDU 2009 求数列的和
题目链接:HDU 2009 Description 数列的定义如下: 数列的第一项为n,以后各项为前一项的平方根,求数列的前m项的和. Input 输入数据有多组,每组占一行,由两个整数n(n< ...
- HDU 整除的尾数 2099
解题思路:很简单的一道水题,这几天比较忙,没怎么刷题,找找自信,很快1A. 还可以,嘿嘿 #include<cstdio> #include<cstring> #inclu ...
- Hdu2099 整除的尾数
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2099 Problem Description 一个整数,只知道前几位,不知道末二位,被另一个整数除尽了 ...
随机推荐
- Python的第3堂课
20181119笔记 一.内存管理相关 ①Cpython解释器的垃圾回收机制 什么是垃圾:当一个值没有被绑定任何变量名(即该值的引用计数为零时),该值就是垃圾. 垃圾回收是收回值占用的内存空间. 引用 ...
- 数据结构( Pyhon 语言描述 ) — —第9章:列表
概念 列表是一个线性的集合,允许用户在任意位置插入.删除.访问和替换元素 使用列表 基于索引的操作 基本操作 数组与列表的区别 数组是一种具体的数据结构,拥有基于单个的物理内存块的一种特定的,不变的实 ...
- pytorch 加载数据集
pytorch初学者,想加载自己的数据,了解了一下数据类型.维度等信息,方便以后加载其他数据. 1 torchvision.transforms实现数据预处理 transforms.Totensor( ...
- Spring中线程池的使用
<bean id="threadPoolTaskExecutor" class="org.springframework.scheduling.concurrent ...
- 双线性差值(由于分析sift源码 )
双线性插值 双线性插值,顾名思义就是两个方向的线性插值加起来.所以只要了解什么是线性插值,分别在x轴和y轴都做一遍,就是双线性插值了. 线性插值的概念也非常简单粗暴,就是两个点A,B,要在AB中间插入 ...
- LeetCode 653. Two Sum IV – Input is a BST
Given a Binary Search Tree and a target number, return true if there exist two elements in the BST s ...
- nw335 debian sid x86-64 -- 6 第三方驱动
nw335 debian sid x86-64 -- 6 第三方驱动
- EFCore CodeFirst模型迁移生成数据库备注(mysql)
重写Mysql下sql脚本生成器 using Framework.NetCore.Extensions; using Framework.NetCore.Models; using Microsoft ...
- 【04】在webstorm里Export declarations are not supported by current JavaScript version
[04]在webstorm里Export declarations are not supported by current JavaScript version Export declara ...
- CI - Set CSRF Hash and Cookie
/** * Set CSRF Hash and Cookie * * @return string */ protected function _csrf_set_hash() { if ($this ...