#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的更多相关文章

  1. UVA725 Division (暴力求解法入门)

    uva 725 Division Write a program that finds and displays all pairs of 5-digit numbers that between t ...

  2. UVA725 Division 除法【暴力】

    题目链接>>>>>> 题目大意:给你一个数n(2 <= n <= 79),将0-9这十个数字分成两组组成两个5位数a, b(可以包含前导0,如02345 ...

  3. python from __future__ import division

    1.在python2 中导入未来的支持的语言特征中division(精确除法),即from __future__ import division ,当我们在程序中没有导入该特征时,"/&qu ...

  4. [LeetCode] Evaluate Division 求除法表达式的值

    Equations are given in the format A / B = k, where A and B are variables represented as strings, and ...

  5. 关于分工的思考 (Thoughts on Division of Labor)

    Did you ever have the feeling that adding people doesn't help in software development? Did you ever ...

  6. POJ 3140 Contestants Division 树形DP

    Contestants Division   Description In the new ACM-ICPC Regional Contest, a special monitoring and su ...

  7. 暴力枚举 UVA 725 Division

    题目传送门 /* 暴力:对于每一个数都判断,是否数字全都使用过一遍 */ #include <cstdio> #include <iostream> #include < ...

  8. GDC2016【全境封锁(Tom Clancy's The Division)】对为何对应Eye Tracked System,以及各种优点的演讲报告

    GDC2016[全境封锁(Tom Clancy's The Division)]对为何对应Eye Tracked System,以及各种优点的演讲报告 原文 4Gamer編集部:松本隆一 http:/ ...

  9. Leetcode: Evaluate Division

    Equations are given in the format A / B = k, where A and B are variables represented as strings, and ...

随机推荐

  1. HDU 1041 Computer Transformation (简单大数)

    Computer Transformation http://acm.hdu.edu.cn/showproblem.php?pid=1041 Problem Description A sequenc ...

  2. 处理HTTP状态码

    1.1.4  处理HTTP状态码 上一节介绍HttpClient访问Web资源的时候,涉及HTTP状态码.比如下面这条语句: int statusCode=httpClient.executeMeth ...

  3. 使用ADO连接oracle数据库“未找到提供程序。该程序可能未正确安装”解决方案

    问题描述:VS2010开发的C++程序,在一台Win7旗舰版的已安装Oracle客户端的PC上连接不上Oracle,提示“未找到提供程序.该程序可能未正确安装”,其他语言编写的程序比如C#是可以成功连 ...

  4. Spark源码分析(二)-SparkContext创建

    原创文章,转载请注明: 转载自http://www.cnblogs.com/tovin/p/3872785.html  SparkContext是应用启动时创建的Spark上下文对象,是一个重要的入口 ...

  5. nil和NULL

  6. lintcode:形状工厂

    题目 工厂模式是一种常见的设计模式.实现一个形状工厂 ShapeFactory 来创建不同的形状类.这里我们假设只有三角形,正方形和矩形三种形状. 样例 ShapeFactory sf = new S ...

  7. jsp中如何用jstl实现if(){}else if(){}else{}

    <c:choose> <c:when test="${条件}"> 情况1........... </c:when> <c:when tes ...

  8. 扩展 delphi 泛型 以实现类似lambda功能 , C#中的any count first last 等扩展方法

    扩展 delphi 泛型 以实现类似lambda功能 , C#中的any count first last 等扩展方法 在C#中对泛型的扩展,输入参数是泛型本身的内容,返回值则是bool.基于这一点, ...

  9. 文件夹属性中只有"常规"解决办法

    Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\shellex\PropertySheetHandlers] [HK ...

  10. Intellij IDEA的Hibernate简单应用

    1.创建数据库及其表 create database demo;    use demo; CREATE TABLE `user` (   `id` int(10) unsigned NOT NULL ...