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. Redis:slave flush old data造成实例不可用

    一.问题描述 2019-02-22凌晨02:42分前后,收到集群中 [10.32.52.8:6500] 实例不可用告警,登陆管理界面查看此实例在正常运行状态,期间未出现机器宕机或实例直接挂掉的现象. ...

  2. 给文本中的url加超级链接,同时滤过已加过链接的url

    /** * 给文本中的url加超级链接,同时滤过已有链接的url * @param string $str [description] * @return [type] [description] * ...

  3. 你的胃能Hold住未来的食物吗?

    ​ 如果你是一名美食客,那么一定会发现现在越来越多的食物已经发生了翻天覆地的变化,很多食物正在以我们未知的形式出现在生活中,其中最大的莫过于分子美食.你想过吗?当食物发生改变的时候,你的胃是否能够Ho ...

  4. 给你的Kubernetes集群建一个只读账户(防止高管。。。后)

    给你的Kubernetes集群建一个只读账户 需求:我们知道搭完k8s集群会创建一个默认的管理员kubernetes-admin用户该用户拥有所以权限,有一天开发或测试的同学需要登录到k8s集群了解业 ...

  5. Python——3条件判断和循环

    */ * Copyright (c) 2016,烟台大学计算机与控制工程学院 * All rights reserved. * 文件名:text.cpp * 作者:常轩 * 微信公众号:Worldhe ...

  6. string类应用举例

    * Copyright (c) 2016,烟台大学计算机与控制工程学院 * All rights reserved. * 文件名:text.cpp * 作者:常轩 * 微信公众号:Worldhello ...

  7. 前端每日实战:34# 视频演示如何用纯 CSS 创作在文本前后穿梭的边框

    效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/qYepNv 可交互视频教程 此视频 ...

  8. 【一统江湖的大前端(8)】matter.js 经典物理

    目录 [一统江湖的大前端(8)]matter.js 经典物理 一.经典力学回顾 二. 仿真的实现原理 2.1 基本动力学模拟 2.2 碰撞模拟 三. 物理引擎matter.js 3.1 <愤怒的 ...

  9. Fabric 源码学习:如何实现批量管理远程服务器?

    前不久,我写了一篇<Fabric教程>,简单来说,它是一个用 Python 开发的轻量级的远程系统管理工具,在远程登录服务器.执行 Shell 命令.批量管理服务器.远程部署等场景中,十分 ...

  10. Markdown中插入复杂的合并表格方法

    由于Markdown自身的语法限制,不能直接插入有合并单元格的复杂表格. 姓名 学号 专业 张三 2018123456 计算机 赵四 2018222356 自动化 李六 2018666666 信息工程 ...