题目链接>>>>>>

题目大意:
给你一个数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

最新文章

  1. Android之Activity状态的保存和恢复
  2. java web的开发 知识要点
  3. iwebshop 订单存库修改为下单件库存
  4. [DataTable]控件排序事件中用DataView及DataTable排序
  5. minicom installation and configuration on ubuntu
  6. cocos2dx入门分析 hello world
  7. Linux进程实时监控 - htop
  8. JUnit三分钟教程 ---- 快速起步
  9. CentOS 6.4安装(超级详细图解教程)
  10. 如何捕获Wince下form程序的全局异常
  11. linux内存源码分析 - 内存压缩(同步关系)
  12. hdu4064 三进制状态压缩 好题!
  13. JavaScript原型、闭包、继承和原型链等等总结
  14. Celery 在Windows下启动worker时出现错误:ValueError: not enough values to unpack (expected 3, got 0)
  15. Retrofit添加自定义转换器
  16. mongodb副本集数据同步的踩坑
  17. python判断文件和文件夹是否存在、没有则创建文件夹
  18. box-sizing 盒子模型不改变大小
  19. jquery中lhgdialog插件(一)
  20. Java方法命名之“由简入繁”原则

热门文章

  1. 2017CCPC秦皇岛 E题String of CCPC&amp;&amp;ZOJ3985【模拟】
  2. Ubuntu16.04搭建QingdaoU(docker一键式部署)
  3. HDFS2.0架构以及HA详解
  4. window.location详解
  5. Android UI组件之自定义控件实现IP地址控件
  6. 重新看halcon模板匹配
  7. Informatic学习总结_day02
  8. MPI 在Windows10 上安装,使用VS2013编译生成可执行程序
  9. OCM_第十天课程:Section5&mdash;》数据仓库
  10. Win7 x64 svn 服务器搭建