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 ...
随机推荐
- HDU 1217 Arbitrage (Floyd)
Arbitrage http://acm.hdu.edu.cn/showproblem.php?pid=1217 Problem Description Arbitrage is the use of ...
- C# 中Newtonsoft.Json的安装和使用
官网参考:http://json.codeplex.com/ 在程序包管理控制台,键入NuGet命令 install-package Newtonsoft.Json 安装Newtonsoft.Js ...
- 牛 JQuery视频笔记
QX3GLL 包装集 next() nextAll() nextAll("div"); prev();prevAll() end();andSlf(); eq(2);gt(1);l ...
- linux kill命令详解
1.命令格式: kill[参数][进程号] 2.命令功能: 发送指定的信号到相应进程.不指定型号将发送SIGTERM(15)终止指定进程.如果任无法终止该程序可用“-KILL” 参数,其发送的信号为S ...
- MongoDB 安装,启动与基本使用
一.MongoDB简介 MongoDB是一个高性能,开源,无模式的文档型数据库,是当前NoSql数据库中比较热门的一种.它在许多场景下可用于替代传统的关系型数据库或键/值存储方式.Mongo使用C++ ...
- MongoDB (十) MongoDB Limit/限制记录
Limit() 方法 要限制 MongoDB 中的记录,需要使用 limit() 方法. limit() 方法接受一个数字型的参数,这是要显示的文档数. 语法: limit() 方法的基本语法如下 & ...
- Spring学习总结(1)——Spring AOP的概念理解
1.我所知道的aop 初看aop,上来就是一大堆术语,而且还有个拉风的名字,面向切面编程,都说是OOP的一种有益补充等等.一下子让你不知所措,心想着:怪不得 很多人都和我说aop多难多难 .当我看进去 ...
- Eclipse项目的导入跟导出
1.导入项目 当下载了包含Eclipse 项目的源代码文件后,我们可以把它导入到当前的Eclipse 工作区然后编辑和查看.点击菜单File > Import,然后在弹出的Import 对话框中 ...
- JavaPersistenceWithHibernate第二版笔记-第五章-Mapping value types-002使用@Embeddable
一.数据库 二.代码 1. package org.jpwh.model.simple; import javax.persistence.Column; import javax.persisten ...
- 修改图层的symbol(AE+C#)
取出一个图层的symbol 在其基础上对其进行修改 private void button1_Click(object sender, EventArgs e) { mp;nbsp; ...