原题链接

简要题意:

构造一个长为 \(n\) 的数,使得每位均不为 \(0\),且 \(n\) 不被它的各位数字整除。

比方说, \(n = 239\) 是合法的。因为:

\(2 \not | 239\),\(3 \not | 239\),\(9 \not | 239\).

再比方,\(n = 235\) 是不合法的。因为:

\(5 | 235\).

因此,本题是个水构造。

首先 \(n = 1\),显然无解。

否则,考虑以下构造:

\[233 \cdots 33
\]

\[499 \cdots 99
\]

\[277 \cdots 77
\]

\[577 \cdots 77
\]

\[599 \cdots 99
\]

\[899 \cdots 99
\]

\[677 \cdots 77
\]

\[\cdots
\]

(盲猜不下 \(1000\) 种构造,全部合法)

#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std; inline int read(){char ch=getchar();int f=1;while(ch<'0' || ch>'9') {if(ch=='-') f=-f; ch=getchar();}
int x=0;while(ch>='0' && ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();return x*f;} int main(){
int T=read(); while(T--) {
int n=read();
if(n==1) printf("-1\n");
else {
putchar('4');
for(int i=1;i<n;i++) putchar('9');
putchar('\n');
} //499...99
}
return 0;
}

CF1326A 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. Poj 1338 Ugly Numbers(数学推导)

    一.题目大意 本题要求写出前1500个仅能被2,3,5整除的数. 二.题解 最初的想法是从1开始检验该数是否只能被2,3,5整除,方法是这样的,对于一个数,如果它能被2整除,就除以2,如果它能被3整除 ...

  3. Ugly Numbers

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

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

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

  5. 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 ...

  6. 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, ...

  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. WWW 2015:一个神奇的会议

    2015:一个神奇的会议" title="WWW 2015:一个神奇的会议"> 作者:微软亚洲研究院研究员 袁进辉 WWW 2015(24th Internatio ...

  2. IT培训的背后,是“韭菜”的躺赚梦!

    作者:九歌 本文转自公众号:Hack 本文只谈"骗局",不谈其他,绝不引战,如有错误,希望指出我会及时改正 导语 为什么要写这篇文章呢,近些年培训这个话题也比较火,很多在看这篇文章 ...

  3. 关于struct stat

    需要使用struct stat 类型时如果编译不过,修改Makefile: ##CFG_INC := -I$(MPI_DIR)/api/so/##CFG_INC += -I$(BASE_DIR)/pu ...

  4. html|Area

    http://tomys.win/   HTML图片热区Area map的用法只是在上学的时候学习到过,在实际工作中一直没用过,如果 不是这次紧急任务,可能永远都不会想起这个功能.在一些特殊的html ...

  5. 20170220-coroutine

    协程 coroutine 最近频繁的听说到 "协程" 这个词,花了一段时间肤浅的研究了一下.对于 "它是一个什么东西" 有了一个大概的了解. from wiki ...

  6. 【简单版】hexo博客搭建流程梳理

    前言 本文章会为你梳理一个搭建hexo博客的流程 相关网址: Docs: https://hexo.io/docs/ Themes: https://hexo.io/themes/ 安装hexo 准备 ...

  7. 【深入理解Java虚拟机 】类加载器的命名空间以及类的卸载

    类加载器的命名空间 每个类加载器又有一个命名空间,由其以及其父加载器组成 类加载器的命名空间的作用和影响 每个类加载器又有一个命名空间,由其以及其父加载器组成 在每个类加载器自己的命名空间中不能出现相 ...

  8. Eureka 注册中心看这一篇就够了

    服务注册中心是服务实现服务化管理的核心组件,类似于目录服务的作用,主要用来存储服务信息,譬如提供者 url 串.路由信息等.服务注册中心是微服务架构中最基础的设施之一. 在微服务架构流行之前,注册中心 ...

  9. springboot创建,自动装配原理分析,run方法启动

    使用IDEA快速创建一个springboot项目 创建Spring Initializr,然后一直下一步下一步直至完成 选择web,表示创建web项目 运行原理分析 我们先来看看pom.xml文件 核 ...

  10. 它的JS与HTML标签是分离的吗

    一个单的利用JS切换图片的功能写法1: <section> <h2>JS切换图片</h2> <ul class="pictable"> ...