A. Bad Ugly Numbers

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

You are given a integer nn (n>0n>0). Find any integer ss which satisfies these conditions, or report that there are no such numbers:

In the decimal representation of ss:

  • s>0s>0,
  • ss consists of nn digits,
  • no digit in ss equals 00,
  • ss is not divisible by any of it's digits.
Input

The input consists of multiple test cases. The first line of the input contains a single integer tt (1≤t≤4001≤t≤400), the number of test cases. The next tt lines each describe a test case.

Each test case contains one positive integer nn (1≤n≤1051≤n≤105).

It is guaranteed that the sum of nn for all test cases does not exceed 105105.

Output

For each test case, print an integer ss which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for ss, print any solution.

Example
input

Copy
4
1
2
3
4
outputCopy
-1
57
239
6789
Note

In the first test case, there are no possible solutions for ss consisting of one digit, because any such solution is divisible by itself.

For the second test case, the possible solutions are: 2323, 2727, 2929, 3434, 3737, 3838, 4343, 4646, 4747, 4949, 5353, 5454, 5656, 5757, 5858, 5959, 6767, 6868, 6969, 7373, 7474, 7676, 7878, 7979, 8383, 8686, 8787, 8989, 9494, 9797, a

 

For the third test case, one possible solution is 239239 because 239239 is not divisible by 22, 33 or 99 and has three digits (none of which equals zero).

  这一题翻译过来就是,输入一个数字n,然后输出一个n位数且这个n位数不能被它任何数位上的一个数整除,如果不能就输出-1;

  【我们知道当n为1的时候一定不可能但当n为其他值的时候[  按理来说] 都有可能】所以前(n-1)输出7,第n个输出4,就好了;

#include <bits/stdc++.h>

using namespace std;

int main()
{
int t;
cin>>t;
while(t--){
int n;
cin>>n;
if(n==)cout<<"-1"<<'\n';//由题意可以知道当位数为1的时候不管怎样都不可能成立
else{
for(int i=;i<n-;i++){
cout<<"";
}
cout<<""<<'\n';
}
} return ;
}

当然,还可以输出n-1个2,加一个3(如果能被3整除就输入n-2个2和2个3)

hhhhh大佬告诉我的【云膜拜一下大佬】

大佬说,正常人不会想到4和7的==(嘤嘤嘤),正常人想到的是2和3hhhhhhh;

就像这样↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

 #include <bits/stdc++.h>

 using namespace std;

 int main()
{
int t;
cin>>t;
while(t--){
int n;
cin>>n;
if(n==)cout<<"-1"<<'\n';//由题意可以知道当位数为1的时候不管怎样都不可能成立
else if(((n-)*+)%!= ){
for(int i=;i<n-;i++){
cout<<"";
}
cout<<""<<'\n';
}
else { for(int i=;i<n-;i++){
cout<<"";
}
cout<<""<<'\n';
}
}
return ;
}

第一次发博客点个赞鼓励一下呗【嘻嘻嘻嘻嘻嘻嘻】

codeforces 1236 A. Bad Ugly Numbers的更多相关文章

  1. [POJ1338]Ugly Numbers

    [POJ1338]Ugly Numbers 试题描述 Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequ ...

  2. Ugly Numbers

    Ugly Numbers Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 21918 Accepted: 9788 Descrip ...

  3. poj 1338 Ugly Numbers(丑数模拟)

    转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063? viewmode=contents 题目链接:id=1338&q ...

  4. leetcode@ [263/264] Ugly Numbers & Ugly Number II

    https://leetcode.com/problems/ugly-number/ Write a program to check whether a given number is an ugl ...

  5. Geeks Interview Question: Ugly Numbers

    Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence1, 2, 3, 4, 5, 6, 8, 9, ...

  6. Codeforces 385C Bear and Prime Numbers

    题目链接:Codeforces 385C Bear and Prime Numbers 这题告诉我仅仅有询问没有更新通常是不用线段树的.或者说还有比线段树更简单的方法. 用一个sum数组记录前n项和, ...

  7. 136 - Ugly Numbers

     Ugly Numbers  Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3 ...

  8. Ugly Numbers(STL应用)

    题目链接:http://poj.org/problem?id=1338 Ugly Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Sub ...

  9. 丑数(Ugly Numbers, UVa 136)

    丑数(Ugly Numbers, UVa 136) 题目描述 我们把只包含因子2.3和5的数称作丑数(Ugly Number).求按从小到大的顺序的第1500个丑数.例如6.8都是丑数,但14不是,因 ...

随机推荐

  1. PHP RabbitMQ 教程(三)

    发布/订阅 我们在上一节创建了一个工作队列,并假定队列对应的任务传送给了某个客户端.在这一章节我们会做一些完全不一样的东西–我们会发送一条消息到多个消费者,也称之为"发布/订阅"模 ...

  2. RxJava学习笔记(操作符)

    前言 上一篇文章介绍了RxJava的基础知识和简单实现,篇幅已经比较多了,所以把操作符(Operators)相关的内容放在这一篇.有了上一篇文章的基础,相信会比较容易理解操作符相关的内容了. 操作符( ...

  3. 正则表达式之RegExp对象

    1.定义 RegExp对象是原生JavaScript中表示正则表达式的对象:是正则表达式(regular expression)的简写.有一点需要明确知道,正则表达式只能对字符串进行操作. 2.语法 ...

  4. 百度地图API:使用百度定位

    准备工作: 1.申请百度地图API 2.下载百度地图的SDK 3.将SDK包中的BaiduLBS_Android.jar文件放到,项目里的app/libs里面 4.在src/main目录下创建一个名为 ...

  5. 牛奶别乱喝6种最好最差牛奶PK

    ​ 牛奶被认为是最健康的一种食材,而且牛奶柔滑的口感和味道让地球上的每一个人都爱不释口.随着现代工业的发展,牛奶也被加工成各种各样的制品,即便是牛奶本身也有着无数的选择,那么究竟什么样的牛奶好.什么样 ...

  6. bp(net core)+easyui+efcore实现仓储管理系统——入库管理之二(三十八)

    abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...

  7. 我去,你写的 switch 语句也太老土了吧

    昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意.但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:& ...

  8. 达拉草201771010105《面向对象程序设计(java)》第十五周学习总结

    达拉草201771010105<面向对象程序设计(java)>第十四周学习总结 第一部分:理论知识 JAR文件: 1.Java程序的打包:程序编译完成后,程序员 将.class文件压缩打包 ...

  9. 干货--手把手撸vue移动UI框架: 滑动删除

    前言 前几天因为项目需要,用jquery写了一个swiperOut组件,然后我就随便把这个组件翻译成基于Vue的了,有兴趣的朋友可以看下.Github源码(不麻烦的话帮忙start,请各位大爷赏个星星 ...

  10. 一个轻量级的基于 .NET Core 的 ORM 框架 HSQL

    HSQL 是一种轻量级的基于 .NET Core 的数据库对象关系映射「ORM」框架 HSQL 是一种可以使用非常简单且高效的方式进行数据库操作的一种框架,通过简单的语法,使数据库操作不再成为难事.目 ...