UVA 725 UVA 10976 简单枚举
#include<cstdio>
#include<cstring>
int num[];
bool check(int a,int b) {
memset(num,,sizeof num);
if(b>) return false;
if(a<) num[]++;
if(b<) num[]++;
while(a) {
num[a%]++;
a/=;
}
while(b) {
num[b%]++;
b/=;
}
for(int i=;i<;i++) {
if(num[i]>) return false;
}
return true;
}
int main() {
int n,cnt=;
while(~scanf("%d",&n),n!=) {
if(cnt>) printf("\n");cnt++;
int flag=;
for(int i=;i<=/n;i++) {
if(check(i,i*n)) {
flag=;
printf("%05d / %05d = %d\n",i*n,i,n);
}
}
if(flag==) printf("There are no solutions for %d.\n",n);
}
return ;
}
#include<cstdio>
int res[][];
int main() {
int k;
while(~scanf("%d",&k)) {
int x,y;
int cnt=;
for(y=k+;y<=*k;y++) {
if((k*y)%(y-k)==) {
x=(k*y)/(y-k);
res[cnt][]=x;res[cnt++][]=y;
}
}
printf("%d\n",cnt);
for(int i=;i<cnt;i++) {
printf("1/%d = 1/%d + 1/%d\n",k,res[i][],res[i][]);
}
}
return ;
}
UVA 725 UVA 10976 简单枚举的更多相关文章
- UVA 725 division【暴力枚举】
[题意]:输入正整数n,用0~9这10个数字不重复组成两个五位数abcde和fghij,使得abcde/fghij的商为n,按顺序输出所有结果.如果没有找到则输出“There are no solut ...
- 暴力枚举 UVA 725 Division
题目传送门 /* 暴力:对于每一个数都判断,是否数字全都使用过一遍 */ #include <cstdio> #include <iostream> #include < ...
- UVA - 10167 - Birthday Cake (简单枚举)
思路:简单枚举 AC代码: #include <cstdio> #include <cstring> #include <iostream> #include &l ...
- uva 725 Division(暴力模拟)
Division 紫书入门级别的暴力,可我还是写了好长时间 = = [题目链接]uva 725 [题目类型]化简暴力 &题解: 首先要看懂题意,他的意思也就是0~9都只出现一遍,在这2个5位数 ...
- 除法(Division ,UVA 725)-ACM集训
参考:http://www.cnblogs.com/xiaobaibuhei/p/3301110.html 算法学到很弱,连这么简单个问题都难到我了.但我偏不信这个邪,终于做出来了.不过,是参照别人的 ...
- uva 725 Division(除法)暴力法!
uva 725 Division(除法) A - 暴力求解 Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & ...
- UVA.12716 GCD XOR (暴力枚举 数论GCD)
UVA.12716 GCD XOR (暴力枚举 数论GCD) 题意分析 题意比较简单,求[1,n]范围内的整数队a,b(a<=b)的个数,使得 gcd(a,b) = a XOR b. 前置技能 ...
- UVA.725 Division (暴力)
UVA.725 Division (暴力) 题意分析 找出abcdefghij分别是0-9(不得有重复),使得式子abcde/fghij = n. 如果分别枚举每个数字,就会有10^10,肯定爆炸,由 ...
- UVA 1508 - Equipment 状态压缩 枚举子集 dfs
UVA 1508 - Equipment 状态压缩 枚举子集 dfs ACM 题目地址:option=com_onlinejudge&Itemid=8&category=457& ...
随机推荐
- Delphi 发送邮件 通过Office Outlook
Delphi 发送邮件 通过Office Outlook 网上搜到的Delphi邮件发送系统,绝大多数是使用SMTP协议来发送. 但是事实上它们已经过时了,大多数邮件服务器已经屏蔽了Delphi In ...
- git base commond
打开Git Bash 命令:先写 git status, 它会告诉你怎么做 1. git pull (把git库中代码拉下来) 2. $ git status (查看状态) 3. $ gi ...
- Python之实现简单计算器功能
一,需求分析 要求计算一串包含数字+-*/()的类似于3*( 4+ 50 )-(( 100 + 40 )*5/2- 3*2* 2/4+9)*((( 3 + 4)-4)-4)表达式的数值 二,知识点 正 ...
- 淘宝订单数据转CSV
<html> <body> <div id="result"> </div> <div> <textarea st ...
- PHP 神奇的sprintf函数
sprintf 1.定义 sprintf() 函数将字符串进行各种类型的格式化. 2.语法 sprintf(format,arg1,arg2,arg++) format:格式类型. arg1,arg2 ...
- 转!!java泛型
介绍java泛型的一篇文章,通俗易懂! 原文地址:http://www.cnblogs.com/lwbqqyumidi/p/3837629.html 一. 泛型概念的提出(为什么需要泛型)? 首先,我 ...
- reload函数
reload函数 python2中reload()是内置函数,可以直接调用: reload() python3中将reload()函数放到了imp包中,需要先引入imp包: from imp impo ...
- PYTHON 最佳实践指南(转)
add by zhj: 本文参考了The Hitchhiker's Guide to Python,当然也加入了作者的一些东西.The Hitchhiker's Guide to Python 的gi ...
- 详解JMeter函数和变量(转载)
详解JMeter函数和变量(1) JMeter函数可以被认为是某种特殊的变量,它们可以被采样器或者其他测试元件所引用.函数调用的语法如下: ${__functionName(var1,var2,var ...
- Deep Learning -- 数据增强
数据增强 在图像的深度学习中,为了丰富图像训练集,更好的提取图像特征,泛化模型(防止模型过拟合),一般都会对数据图像进行数据增强,数据增强,常用的方式,就是旋转图像,剪切图像,改变图像色差,扭曲图像特 ...