题目链接>>>>>>

题目大意:
给你一个数n(2 <= n <= 79),将0-9这十个数字分成两组组成两个5位数a, b(可以包含前导0,如02345也算),使得a / b = n;列出所有的可能答案。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <cmath> using namespace std; int main()
{
int n, a[], first = ;
while (scanf("%d", &n) != EOF,n) {
if (first) {
first = ;
}
else {
printf("\n");
} //以上是两组数据之间输出空行的技巧
int num1 = , num2 = ;
int side = / n; //这里稍微降低了一下复杂度
int flag1 = ;
for (num1 = ; num1 <= side; num1++) {
int flag = ;
num2 = num1 * n;
a[] = num2 / ;
a[] = num2 / % ;
a[] = num2 / % ;
a[] = num2 / % ;
a[] = num2 % ;
a[] = num1 / ;
a[] = num1 / % ;
a[] = num1 / % ;
a[] = num1 / % ;
a[] = num1 % ;
for (int i = ; i < ; i++) {
for (int j = ; j < ; j++) {
if (j != i && a[i] == a[j]) { //这里判断10位数是否有重复的方法
flag = ;
}
}
}
if (flag) {
for (int i = ; i < ; i++)cout << a[i]; cout << " / "; //注意这里"/"和"="左右两边都有空格
for (int i = ; i < ; i++)cout << a[i]; cout << " = " << n << endl;
flag1 = ;
}
}
if (flag1 == ) {
printf("There are no solutions for %d.\n", n);
}
}
return ;
}

2018-04-08

UVA725 Division 除法【暴力】的更多相关文章

  1. UVA725 Division (暴力求解法入门)

    uva 725 Division Write a program that finds and displays all pairs of 5-digit numbers that between t ...

  2. uva 725 Division(暴力模拟)

    Division 紫书入门级别的暴力,可我还是写了好长时间 = = [题目链接]uva 725 [题目类型]化简暴力 &题解: 首先要看懂题意,他的意思也就是0~9都只出现一遍,在这2个5位数 ...

  3. Codeforces Beta Round #91 (Div. 2 Only) A. Lucky Division【暴力/判断是不是幸运数字4,7的倍数】

    A. Lucky Division time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  4. hdu 2615 Division(暴力)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2615 题解:挺简单的暴力枚举,小小的分治主要是看没人写题解就稍微写一下 #include <io ...

  5. UVa725 - Division

    #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; int ...

  6. UVA 725 division【暴力枚举】

    [题意]:输入正整数n,用0~9这10个数字不重复组成两个五位数abcde和fghij,使得abcde/fghij的商为n,按顺序输出所有结果.如果没有找到则输出“There are no solut ...

  7. uva725(除法)

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

  8. 3. Python 简介

    3. Python 简介 下面的例子中,输入和输出分别由大于号和句号提示符 ( >>> 和 ... ) 标注:如果想重现这些例子,就要在解释器的提示符后,输入 (提示符后面的) 那些 ...

  9. require.js实现js模块化编程(一)

    1.认识require.js: 官方文档:http://requirejs.org/RequireJS是一个非常小巧的JavaScript模块载入框架,是AMD规范最好的实现者之一.最新版本的Requ ...

随机推荐

  1. js 获取当前日期或者前、后N天yyyy-MM-dd的方法

    //js获取当前日期.当前日期前.后N天的标准年月日 //day=0为当前天,day=7为前7天,day=-7为当前日期的后7天 function getstartdate(day) {        ...

  2. hashMap之jdk1.7和jdk1.8

    参考链接: http://allenwu.itscoder.com/hashmap-analyse https://tech.meituan.com/java-hashmap.html

  3. win10如何获得管理员权限_百度经验

    win10如何获得管理员权限_百度经验http://jingyan.baidu.com/article/0aa223755448db88cd0d6450.html 在右下方任务栏的“搜索web和win ...

  4. [转]gcc -ffunction-sections -fdata-sections -Wl,–gc-sections 参数详解

    背景 有时我们的程序会定义一些暂时使用不上的功能和函数,虽然我们不使用这些功能和函数,但它们往往会浪费我们的ROM和RAM的空间.这在使用静态库时,体现的更为严重.有时,我们只使用了静态库仅有的几个功 ...

  5. Python3 日期时间 相关模块(time(时间) / datatime(日期时间) / calendar(日历))

    Python3 日期时间 相关模块(time(时间) / datatime(日期时间) / calendar(日历)) 本文由 Luzhuo 编写,转发请保留该信息. 原文: http://blog. ...

  6. caffe中使用python定义新的层

    转载链接:http://withwsf.github.io/2016/04/14/Caffe-with-Python-Layer/ Caffe通过Boost中的Boost.Python模块来支持使用P ...

  7. Device Tree常用方法解析【转】

    转自:https://blog.csdn.net/airk000/article/details/21345159 Device Tree常用方法解析 Device Tree在Linux内核驱动中的使 ...

  8. java多线程系列五、并发容器

    一.ConcurrentHashMap 1.为什么要使用ConcurrentHashMap 在多线程环境下,使用HashMap进行put操作会引起死循环,导致CPU利用率接近100%,HashMap在 ...

  9. mybatis异常分析jdbcType

    Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException: Error setti ...

  10. (并发编程)进程IPC,生产者消费者模型,守护进程补充

    一.IPC(进程间通信)机制进程之间通信必须找到一种介质,该介质必须满足1.是所有进程共享的2.必须是内存空间附加:帮我们自动处理好锁的问题 a.from multiprocessing import ...