HALF<水题>
2024-08-25 01:30:29
题意:
找出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;
}
最新文章
- [Algorithm] 局部敏感哈希算法(Locality Sensitive Hashing)
- Java Math 取整的方式
- socket的IO多路复用
- 003_关于IntellJ IDE 2016 1. 4的使用
- PHP时区配置
- 神奇的Bank系统之旅哦
- CodeSnippetsLibrary的使用方法
- c++ 字符串函数用法举例
- android--多View切换viewpager
- poj 2528 Mayor&#39;s posters(线段树)
- 【转】 C++中如何在一个构造函数中调用另一个构造函数
- 面向对象的程序设计(二)理解各种方法和属性typeof、instanceof、constructor、prototype、__proto__、isPrototypeOf、hasOwnProperty
- LInkedList集合练习
- 重写boost内存池
- [Redux] Extracting Container Components -- VisibleTodoList
- Delphi中ShellExecute使用详解(详细解释10种显示状态)
- how to increase an regular array length in java?
- canvas常用api
- 关于OSError: [WinError 10038] 在一个非套接字上尝试了一个操作。
- NodeJs连接操作MongoDB数据库
热门文章
- Implementing a builder: Zero and Yield
- delphi 容错提示语句汇总
- 转载–移动互联网终端的touch事件,touchstart, touchend, touchmove
- iOS之文件解析
- ios中判断当前手机的网络状态
- NYOJ-448 寻找最大数(贪心)
- JPA 系列教程11-复合主键-2个@Id
- Thrift源码解析--TBinaryProtocol
- linex下部署发布web项目
- [bzoj3196][Tyvj 1730][二逼平衡树] (线段树套treap)