题意:

找出n/d=0.5的所有数。输入:test,x(代表n的位数,1<=x<=4).并且n和d的每一个位数不能有重复,也不能是0。
输入:
1
1
输出:
the form 1/2 = 0.5.
the form 2/4 = 0.5.
the form 3/6 = 0.5.
the form 4/8 = 0.5.
the form 6/12 = 0.5.
the form 7/14 = 0.5.
the form 8/16 = 0.5.
the form 9/18 = 0.5.
#include<cstdio>
#include<cmath>
using namespace std;
int main ()
{
int a[10];
int t;scanf("%d",&t);
while(t--){
int n;scanf("%d",&n);
int mi=pow(10,n-1);
int ma=pow(10,n)-1;
for(int k=mi;k<=ma;k++){
for(int i=0;i<10;i++) a[i]=0;
int A=k;
int B=2*A;
while(A) a[A%10]++ , A/=10;
while(B) a[B%10]++ , B/=10;
int flag=1;
for(int i=0;i<10;i++) if(a[0]||a[i]>1) flag=0;
if(flag) printf("the form %d/%d = 0.5.\n",k,2*k);
}
}
return 0;
}

最新文章

  1. [Algorithm] 局部敏感哈希算法(Locality Sensitive Hashing)
  2. Java Math 取整的方式
  3. socket的IO多路复用
  4. 003_关于IntellJ IDE 2016 1. 4的使用
  5. PHP时区配置
  6. 神奇的Bank系统之旅哦
  7. CodeSnippetsLibrary的使用方法
  8. c++ 字符串函数用法举例
  9. android--多View切换viewpager
  10. poj 2528 Mayor&#39;s posters(线段树)
  11. 【转】 C++中如何在一个构造函数中调用另一个构造函数
  12. 面向对象的程序设计(二)理解各种方法和属性typeof、instanceof、constructor、prototype、__proto__、isPrototypeOf、hasOwnProperty
  13. LInkedList集合练习
  14. 重写boost内存池
  15. [Redux] Extracting Container Components -- VisibleTodoList
  16. Delphi中ShellExecute使用详解(详细解释10种显示状态)
  17. how to increase an regular array length in java?
  18. canvas常用api
  19. 关于OSError: [WinError 10038] 在一个非套接字上尝试了一个操作。
  20. NodeJs连接操作MongoDB数据库

热门文章

  1. Implementing a builder: Zero and Yield
  2. delphi 容错提示语句汇总
  3. 转载–移动互联网终端的touch事件,touchstart, touchend, touchmove
  4. iOS之文件解析
  5. ios中判断当前手机的网络状态
  6. NYOJ-448 寻找最大数(贪心)
  7. JPA 系列教程11-复合主键-2个@Id
  8. Thrift源码解析--TBinaryProtocol
  9. linex下部署发布web项目
  10. [bzoj3196][Tyvj 1730][二逼平衡树] (线段树套treap)