除法 Division
除法
题目链接: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的更多相关文章
- 暴力求解——除法 Division,UVa 725
Description Write a program that finds and displays all pairs of 5-digit numbers that between them u ...
- java入门学习(九) 算术运算符
请大家关注我的博客www.taomaipin.com 运算符在java基础中也占有着举足轻重的位置,我们当然要学会它.java 其实和其他计算机语言一样,基本的算术运算符基本一样,让我们看看 有哪些算 ...
- JAVA_SE基础——11.Java中的运算符
在程序设计中,运算符应用得十分广泛,通过运算符可以将两个变量进行任意运算.数学中的"+"."-"."*"."/"运算符同 ...
- Java基础__Java中常用数学类Math那些事
测试 package Cynical_Gary; public class Cynical_Text { public static void main(String[] args){ System ...
- 01_02_py
1基础知识 1.自然语言 (natural language) 是人们交流所使用的语言,例如英语.西班牙语和法语.它们不是人为设计出来的(尽管有人试图这样做):而是自然演变而来. 2.形式语言 (fo ...
- [LeetCode] Evaluate Division 求除法表达式的值
Equations are given in the format A / B = k, where A and B are variables represented as strings, and ...
- uva 725 Division(除法)暴力法!
uva 725 Division(除法) A - 暴力求解 Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & ...
- [Swift]LeetCode399. 除法求值 | Evaluate Division
Equations are given in the format A / B = k, where A and B are variables represented as strings, and ...
- [Swift]LeetCode553. 最优除法 | Optimal Division
Given a list of positive integers, the adjacent integers will perform the float division. For exampl ...
随机推荐
- 新浪微博的账号登录及api操作
.sina.php <?php /** * PHP Library for weibo.com * * @author */ class sinaPHP { function __constru ...
- 非正规写法获取不到tr,td
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Java学习笔记(八)——封装
一.封装 1.定义 将类的信息隐藏在类的内部,不允许外部程序直接进行访问,而是通过该类提供的方法来实现对隐藏信息的操作和方法. 2.优点 (1)只能通过规定的方法访问数据 (2)隐藏类的细节,方便修改 ...
- 获取APK签名
获取apk签名工具类 import android.content.Context; import android.content.pm.PackageInfo; import android.con ...
- Python入门神图
国外某小哥制作的Python入门神图
- Java类与对象的基础学习
1. 请输入并运行以下代码,得到什么结果? public class Test{ public static void main(String args[]){ Foo obj1=new Foo(); ...
- 本BLOG简介(内有一道UVa524素数环进阶版)【B001】
[B001]Hi,大家好,今天我的博客第一天开通,今天奉上开博题,出自首都师师范大学附属中学OJ(题号未知在练习场中)原题为UVa524,题目要求如下: [难度B]—————————————————— ...
- 模拟 Codeforces Round #288 (Div. 2) A. Pasha and Pixels
题目传送门 /* 模拟水题:给定n*m的空白方格,k次涂色,将(x,y)处的涂成黑色,判断第几次能形成2*2的黑色方格,若不能,输出0 很挫的判断四个方向是否OK */ #include <cs ...
- NSDictionary、NSMutableDictionary及其枚举器的用法
.不可变词典NSDictionary 字典初始化 NSNumber *numObj = [NSNumber numberWithInt:]; 以一个元素初始化 NSDictionary *dic = ...
- 如何让Ue4画面产生振动效果
可以使用CameraShake蓝图类,对应的C++类为UCameraShake. 这个类是通过修改PlayerController来达到效果