除法

题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=84562#problem/A

题意:

输入正整数n按从小到大的顺序输出所有形如abcde/fghij=n的表达式,其中

a~j恰好为0~9的一个排列(可以有前导0),2<=n<=79。

Sample Input

61
62
0

Sample Output

There are no solutions for 61.

79546 / 01283 = 62
94736 / 01528 = 62

分析:

由fghij可以算出abcde,所有我们只需要枚举fghij,然后判断abcdefghij这些数字是否都不相等即可。

注意输出的格式(空格)。

 #include<iostream>
#include<cstdio>
using namespace std;
int b[];
int per(int x,int y)
{int i;
if(y>) return ;
for(i=;i<;i++)
b[i]=;
if(x<) b[]=;
while(x)
{
b[x%]=;
x=x/;
}
while(y)
{
b[y%]=;
y=y/;
}
int sum=;
for( i=;i<;i++)
sum=sum+b[i];
return (sum==);
}
int main()
{
int n,c=,i,count;
scanf("%d",&n);
while(n)
{
if(c++) cout<<endl;
count=;
for(i=;i<;i++)
{
if(per(i,i*n))
{
printf("%05d / %05d = %d\n",i*n,i,n);
count++;
}
}
if(count==)
printf("There are no solutions for %d.\n",n);
scanf("%d",&n);
} return ;
}

除法 Division的更多相关文章

  1. 暴力求解——除法 Division,UVa 725

    Description Write a program that finds and displays all pairs of 5-digit numbers that between them u ...

  2. java入门学习(九) 算术运算符

    请大家关注我的博客www.taomaipin.com 运算符在java基础中也占有着举足轻重的位置,我们当然要学会它.java 其实和其他计算机语言一样,基本的算术运算符基本一样,让我们看看 有哪些算 ...

  3. JAVA_SE基础——11.Java中的运算符

    在程序设计中,运算符应用得十分广泛,通过运算符可以将两个变量进行任意运算.数学中的"+"."-"."*"."/"运算符同 ...

  4. Java基础__Java中常用数学类Math那些事

     测试 package Cynical_Gary; public class Cynical_Text { public static void main(String[] args){ System ...

  5. 01_02_py

    1基础知识 1.自然语言 (natural language) 是人们交流所使用的语言,例如英语.西班牙语和法语.它们不是人为设计出来的(尽管有人试图这样做):而是自然演变而来. 2.形式语言 (fo ...

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

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

  7. uva 725 Division(除法)暴力法!

    uva 725  Division(除法) A - 暴力求解 Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & ...

  8. [Swift]LeetCode399. 除法求值 | Evaluate Division

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

  9. [Swift]LeetCode553. 最优除法 | Optimal Division

    Given a list of positive integers, the adjacent integers will perform the float division. For exampl ...

随机推荐

  1. 豆瓣的账号登录及api操作

    .douban.php <?php /** * PHP Library for douban.com * * @author */ class doubanPHP { function __co ...

  2. OpenMesh 之向量操作

    OpenMesh 提供了许多可供使用的向量操作函数,使用特别方便. 计算距离: 从官方文档可以看到OpenMesh提供了5个函数,分别为 Scalar length() const        // ...

  3. 【java IO File】统计项目代码总共多少行

    统计项目代码总共有多少行 思想: 1.首先将不需要迭代的文件夹,保存在集合中,不满足的就是需要迭代的文件夹 2.将需要进行统计行数的代码文件保存在集合中,满足的就是需要计算文件行数的文件 3.迭代方法 ...

  4. 使用J2SE API读取Properties文件的六种方法

    1.使用java.util.Properties类的load()方法示例: InputStream in = lnew BufferedInputStream(new FileInputStream( ...

  5. 基线 css

    原文地址:http://blog.jobbole.com/31926/ 英文原文:CSS Baseline,编译:飞鸟分享 译者注:网页设计布局中一直比较流行网格对齐,但只是针对水平的对齐,很少或者没 ...

  6. node.js整理 02文件操作-常用API

    NodeJS不仅能做网络编程,而且能够操作文件. 拷贝 小文件拷贝 var fs = require('fs'); function copy(src, dst) { fs.writeFileSync ...

  7. [xsd学习]xsd介绍

    一直以来项目中对xml格式的判断使用的都是dtd格式,直到最近才发现,不知何时都已经转为xsd来进行判断和校验,于是今天专门找资料看下,不得不说,对于这类资料的入门,w3cschool真是个不错的资料 ...

  8. 20145223《Java程序设计》实验报告3

    20145223 实验三<敏捷开发与XP实践> 实验内容 使用git上传代码 使用git相互更改代码 实验步骤: 一.使用git上传代码 $ git push 1.找到需要push的文件所 ...

  9. NSDICTIONARY获取内容的CRASH

    NSString *path = [self.dataPath stringByAppendingPathComponent:@"dummy.plist"]; NSMutableD ...

  10. 如何在UMG中上显示3D物体

    http://www.unrealchina.net/forum.php?mod=viewthread&tid=101548 个人认为可以使用关卡系统,搞个空关卡来做渲染比较好