UVa725 - Division
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = ;
int vis[maxn]; int check(int n, int x)
{
memset(vis, , sizeof(vis));
int a, t;
t = n / x;
if(t < ) vis[] = ; //这步极为关键,刚开始没有这步,测试样例都过不了
//找了半天才发现。其实,如果出现前导0,一定是在
//分母,不可能出现在分子。
while(n)
{
a = n % ; //标记整数的每一位数字。
vis[a] = ;
n /= ;
}
while(t)
{
a = t % ;
vis[a] = ;
t /= ;
}
for(int i = ; i < ; i++)
{
if(!vis[i]) return ; // 当有一个没有标记时,直接返回0,说明不符合条件。
}
return ;
}
int main()
{
int n, flag, kase = ;
while(~scanf("%d", &n) && n)
{
flag = ;
if(kase++) printf("\n"); //刚开始这行写在下面注释的地方《1》,WA了一发,表示很迷茫
//因为并没有提示PE,注意UVa的风格,这种题一定要小心,只是在
//两行中间取空行,而第一行之前和最后一行之后是没有空行的,此处
//与HDU是有点区别的。
for(int i = ; i <= ; i++)
{
int t = i % n;
//int k = i / n;
if(t == && check(i, n)) //整除并且包含0 ~ 9,则输出
{
flag = ;
printf("%05d / %05d = %d\n", i, i/n, n); //有前导0,则用%05d的方式,左边一个可以不用。
}
}
//if(kase++) printf("\n"); 《1》
if(!flag) printf("There are no solutions for %d.\n", n); //之前没有符合条件的,则输出这一行。
//printf("\n"); //注释掉了前面跟kase有关的一行代码,WA了一发。
}
return ;
}
UVa725 - Division的更多相关文章
- UVA725 Division (暴力求解法入门)
uva 725 Division Write a program that finds and displays all pairs of 5-digit numbers that between t ...
- UVA725 Division 除法【暴力】
题目链接>>>>>> 题目大意:给你一个数n(2 <= n <= 79),将0-9这十个数字分成两组组成两个5位数a, b(可以包含前导0,如02345 ...
- python from __future__ import division
1.在python2 中导入未来的支持的语言特征中division(精确除法),即from __future__ import division ,当我们在程序中没有导入该特征时,"/&qu ...
- [LeetCode] Evaluate Division 求除法表达式的值
Equations are given in the format A / B = k, where A and B are variables represented as strings, and ...
- 关于分工的思考 (Thoughts on Division of Labor)
Did you ever have the feeling that adding people doesn't help in software development? Did you ever ...
- POJ 3140 Contestants Division 树形DP
Contestants Division Description In the new ACM-ICPC Regional Contest, a special monitoring and su ...
- 暴力枚举 UVA 725 Division
题目传送门 /* 暴力:对于每一个数都判断,是否数字全都使用过一遍 */ #include <cstdio> #include <iostream> #include < ...
- GDC2016【全境封锁(Tom Clancy's The Division)】对为何对应Eye Tracked System,以及各种优点的演讲报告
GDC2016[全境封锁(Tom Clancy's The Division)]对为何对应Eye Tracked System,以及各种优点的演讲报告 原文 4Gamer編集部:松本隆一 http:/ ...
- Leetcode: Evaluate Division
Equations are given in the format A / B = k, where A and B are variables represented as strings, and ...
随机推荐
- 安装mysql之后,存入中文出现乱码 02
现在出现这个问题,将编码字符串改成utf8 之后 数据表 还是不能存储中文. 看如下两张图,应该会有启发: 这下应该明白了吧.
- Java:内部类
1.内部类的定义: 一个内部类可以定义在另一个类里,可以定义在函数里,甚至可以作为一个表达式的一部分. 2.内部类的分类: Java中的内部类共分为四种: 成员内部类member inner clas ...
- hdu 4112 Break the Chocolate(ceil floor)
规律题: #include<stdio.h> #include<math.h> #define eps 1e-8 int main() { int _case; int n,m ...
- Shell脚本基础II
1.shell算术运算 1)加法 r=`expr 4 + 5`(注意! '4' '+' '5' 这三者之间要有空白) r=$[ 4 + 5 ] r=$(( 4 + 5 )) echo $r 2)乘法 ...
- Qt中的键盘事件,以及焦点的设置(比较详细)
Qt键盘事件属于Qt事件系统,所以事件系统中所有规则对按键事件都有效.下面关注点在按键特有的部分: focus 一个拥有焦点(focus)的QWidget才可以接受键盘事件.有输入焦点的窗口是活动窗口 ...
- MakeObjectInstance的前世今生(关键是ECX的何时入栈以及Self指针何时存储的)
高手们的文章有很大启发,但是总有些小错,也有没交代清楚的,以下是我的理解: 编译器编译MainWndProc的时候,它是一个正常Delphi普通函数,MakeObjectInstance对它做变换是运 ...
- 让浏览器屏蔽js
有时候为了测试js是否做到了渐进增强,需要屏蔽下js 做法: Internet选项>>安全>>自定义级别 禁用java小程序脚本和活动脚本 有的浏览器调试器直接就有这个功能
- 【Netty学习】Netty 4.0.x版本和Flex 4.6配合
笔者的男装网店:http://shop101289731.taobao.com .冬装,在寒冷的冬季温暖你.新品上市,环境选购 =================================不华丽 ...
- Data Flow ->> Import Column & Export Column
这两个transformation的作用是把DT_TEXT, DT_NTEXT, DT_IMAGE类型的数据在文件系统和数据库间导出或者导入.比如把某个数据库表的image类型的字段导出到文件系统成为 ...
- cmd执行mssql脚本或者执行mysql脚本
private static int ExecuteMSSql(DbInfo db, string sqlPath) { Console.WriteLine("=============== ...