暴力枚举 UVA 725 Division
/*
暴力:对于每一个数都判断,是否数字全都使用过一遍
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <queue>
using namespace std; const int MAXN = 1e4 + ;
const int INF = 0x3f3f3f3f;
int vis[]; bool ok(int x, int y)
{
memset (vis, , sizeof (vis));
for (int i=; i<=; ++i)
{
vis[x%]++; vis[y%]++;
if (vis[x%] > || vis[y%] > ) return false;
x /= ; y /= ;
} return true;
} int main(void) //UVA 725 Division
{
//freopen ("UVA_725.in", "r", stdin); int n, cnt = ;
while (scanf ("%d", &n) == )
{
if (n == ) break;
if (cnt++) puts (""); int one = ;
for (int i=; i<=/n; ++i)
{
if (i * n > ) break;
if (ok (i, i*n) == true)
{
printf ("%05d / %05d = %d\n", n*i, i, n); one++;
}
} if (!one) printf ("There are no solutions for %d.\n", n);
} return ;
} /*
There are no solutions for 61.
*/
暴力枚举 UVA 725 Division的更多相关文章
- UVA.725 Division (暴力)
UVA.725 Division (暴力) 题意分析 找出abcdefghij分别是0-9(不得有重复),使得式子abcde/fghij = n. 如果分别枚举每个数字,就会有10^10,肯定爆炸,由 ...
- uva 725 Division(除法)暴力法!
uva 725 Division(除法) A - 暴力求解 Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & ...
- uva 725 Division(暴力模拟)
Division 紫书入门级别的暴力,可我还是写了好长时间 = = [题目链接]uva 725 [题目类型]化简暴力 &题解: 首先要看懂题意,他的意思也就是0~9都只出现一遍,在这2个5位数 ...
- UVA 725 division【暴力枚举】
[题意]:输入正整数n,用0~9这10个数字不重复组成两个五位数abcde和fghij,使得abcde/fghij的商为n,按顺序输出所有结果.如果没有找到则输出“There are no solut ...
- uva 725 DIVISION (暴力枚举)
我的56MS #include <cstdio> #include <iostream> #include <string> #include <cstrin ...
- UVa 725 Division (枚举)
题意 : 输入正整数n,按从小到大的顺序输出所有形如abcde/fghij = n的表达式,其中a-j恰好为数字0-9的一个排列(可以有前导0),2≤n≤79. 分析 : 最暴力的方法莫过于采用数组存 ...
- uva 725 division(水题)——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABVMAAAOHCAIAAAClwESxAAAgAElEQVR4nOydybGturJFcQEPfgQu4A
- 暴力枚举 UVA 10976 Fractions Again?!
题目传送门 /* x>=y, 1/x <= 1/y, 因此1/k - 1/y <= 1/y, 即y <= 2*k */ #include <cstdio> #inc ...
- UVA 725 – Division
Description Write a program that finds and displays all pairs of 5-digit numbers that between them ...
随机推荐
- java笔记--关于int和byte[]的转换
关于int和byte[]数组的转换 --如果朋友您想转载本文章请注明转载地址"http://www.cnblogs.com/XHJT/p/3891747.html "谢谢-- 众所 ...
- NGUI 学习笔记实战之二——商城数据绑定(Ndata)
上次笔记实现了游戏商城的UI界面,没有实现动态数据绑定,所以是远远不够的.今天采用NData来做一个商城. 如果你之前没看过,可以参考上一篇博客 NGUI 学习笔记实战——制作商城UI界面 ht ...
- HDOJ 1203 I NEED A OFFER!(01背包)
10397507 2014-03-25 23:30:21 Accepted 1203 0MS 480K 428 B C++ 泽泽 题目链接:http://acm.hdu.edu.cn/showprob ...
- BZOJ2904
找了一个晚上的资料,拼凑出来这么一个东西: 1) 如果是完全平方数返回12) 如果可以表示成形如$x^2+y^2$的形式输出2.这要求该数质因数分解后形如$4k+3$的质因数次数都是偶数.3) 如果该 ...
- PhpStorm主题
图的github仓库有很多编辑器的主题,jetbrains目录下都是PhpStorm支持的主题 1.到http://daylerees.github.io/预览各个主题的风格,找到自己喜欢的: 2.在 ...
- MVC ViewBag和ViewData的区别
在MVC3开始,视图数据可以通过ViewBag属性访问,在MVC2中则是使用ViewData.MVC3中保留了ViewData的使用.ViewBag 是动态类型(dynamic),ViewData 是 ...
- iOS 和 Android 触摸事件传递
先看文章,写得很好 ios 触摸事件传递 http://www.cnblogs.com/Quains/p/3369132.html 另外一篇 http://blog.csdn.net/yongyinm ...
- iOS 的UIWindow 类研究
今日发现如果想做出漂亮的界面效果,就需要仔细研究一下UIWindow这个类.现在还不清楚为什么要有这么一个UIWindow类,它跟UIView的根本区别是什么?和Android中的什么类比较相像.先做 ...
- Android 中的code sign
Android 中和ios中都有code sign.它们的目的一样,都是要保证程序的可靠性,最基本实现原理也一样.但是sign的过程比较不同. 下面记录一点Android sign的重要知识. 请参看 ...
- 桐桐的贸易--WA
问题 A: 桐桐的贸易 时间限制: 1 Sec 内存限制: 64 MB提交: 15 解决: 2[提交][状态][讨论版] 题目描述 桐桐家在Allianceance城,好友ROBIN家在Horde ...