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 一个整数,只知道前几位,不知道末二位,被另一个整数除尽了 ...
随机推荐
- 【转】ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
为了加强安全性,MySQL5.7为root用户随机生成了一个密码,在error log中,关于error log的位置,如果安装的是RPM包,则默认是/var/log/mysqld.log. 一般可通 ...
- LeetCode(125) Valid Palindrome
题目 Given a string, determine if it is a palindrome, considering only alphanumeric characters and ign ...
- Makefile学习(二)----生成静态库文件
Lunix下编译静态库文件: .o后缀文件:编译生成的中间代码文件: .a后缀文件:静态库文件,编译的时候会合到可执行程序中,文件比较大: .so后缀文件:动态库文件,只是一个指向,不会合到可执行程序 ...
- HDU 2829 斜率优化DP Lawrence
题意:n个数之间放m个障碍,分隔成m+1段.对于每段两两数相乘再求和,然后把这m+1个值加起来,让这个值最小. 设: d(i, j)表示前i个数之间放j个炸弹能得到的最小值 sum(i)为前缀和,co ...
- luogu3809 后缀排序 后缀数组
ref and 挑战程序设计竞赛. 主要是发现自己以前写得代码太难看而且忘光了,而且我字符串死活学不会啊,kmp这种东西我都觉得是省选+难度啊QAQ #include <iostream> ...
- 4C. Stars
4C. Stars Time Limit: 2000ms Case Time Limit: 2000ms Memory Limit: 65536KB 64-bit integer IO forma ...
- MySQL binlog_rows_query_log_events在线设置无效
binlog_rows_query_log_events 对binlog_format=row有效,设为true后可以在binary log中记录原始的语句 官方文档显示binlog_rows_que ...
- Python2.6.6升级2.7.3
Python2.7替换2.6: 1.下载Python-2.7.3 #wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2 2.解压 ...
- [ZJOI2005]午餐 (贪心,动态规划)
题目描述 上午的训练结束了,THU ACM小组集体去吃午餐,他们一行N人来到了著名的十食堂.这里有两个打饭的窗口,每个窗口同一时刻只能给一个人打饭.由于每个人的口味(以及胃口)不同,所以他们要吃的菜各 ...
- 自己写的java返回结果集封装
import java.io.Serializable; import com.fasterxml.jackson.core.JsonProcessingException; import com.f ...