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 ...
随机推荐
- POJ 1459
#include<iostream> #define MAXN 105 #include"queue" #define big_num 100000000 using ...
- Android中 ListView 详解(二)
本文版权归 csdn noTice501 所有,转载请详细标明原作者及出处,以示尊重! 作者:noTice501 原文:http://blog.csdn.net/notice520/article/d ...
- 安装mysql之后,存入中文出现乱码 02
现在出现这个问题,将编码字符串改成utf8 之后 数据表 还是不能存储中文. 看如下两张图,应该会有启发: 这下应该明白了吧.
- 在WCF中使用消息队列
在一些大型的解决方案中,假设我们的服务没有办法一直在线,或者因为这样那样的原因宕机了,有没有什么办法让客户端的影响最小化呢?答案是可以通过消息队列的方式,哪怕服务是没有在线的,客户端依然可以继续操作. ...
- (转)价值240万的photoshop中文教程,错过了后悔都来不及 (吹得好响)
PS抠图方法 一.魔术棒法——最直观的方法 适用范围:图像和背景色色差明显,背景色单一,图像边界清晰. 方法意图:通过删除背景色来获取图像. 方法缺陷:对散乱的毛发没有用. 使用方法:1.点击“魔 ...
- svn教程
安装过程: 1.下载软件后,双击程序进行安装,点击“Next”: 2.在许可证协议页面,选择“I Accept the terms in the License Agreement”,点击“Next” ...
- WebSocket 是什么原理?为什么可以实现持久连接
你可以把 WebSocket 看成是 HTTP 协议为了支持长连接所打的一个大补丁,它和 HTTP 有一些共性,是为了解决 HTTP 本身无法解决的某些问题而做出的一个改良设计.在以前 HTTP 协议 ...
- 配置sshd_config中的PermitRootLogin设置root登录或者禁止root登录
在etc的sshd_config文件中,默认有PermitRootLogin no的配置,这个的意思是禁止root用户登录,如果想要允许root登录,需要su root用户到sshd_config下进 ...
- Oracle ->> Oracle下生成序列的方法
用hierachical query,即connect by配合dual表生成序列,mod这个是取余函数,生成group factor.最后面的connect by rownum <= 100可 ...
- [转]C:int型指针
开源中国:http://my.oschina.net/lotte1699/blog/142538 网页快照:http://www.piaocafe.com/295977937/139381567037 ...