Codeforces 1326A Bad Ugly Numbers

看完题目,第一直觉,质数肯定满足题意,再看数据范畴,\(1≤n≤10^5\),

质数线性筛仅能做到 n=7 的情况,即处理到10000000.

重新读题,发现是一道构造。

当\(n != 1\)时,另首位为\(2\),其他均为\(9\)即可

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, a[N], i, j;
void solve() {
cin >> n;
if (n == 1)cout << -1 << endl;
else {
cout << 2;
for (i = 1; i < n; ++i)
cout << 9;
cout << endl;
}
} int main() {
//freopen("in.txt", "r", stdin);
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t; cin >> t;
while (t--)solve();
}

Codeforces 1326A Bad Ugly Numbers (思维)的更多相关文章

  1. codeforces 1236 A. Bad Ugly Numbers

    A. Bad Ugly Numbers time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. [codeforces 55]D. Beautiful numbers

    [codeforces 55]D. Beautiful numbers 试题描述 Volodya is an odd boy and his taste is strange as well. It ...

  3. [POJ1338]Ugly Numbers

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

  4. Ugly Numbers

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

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

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

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

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

  8. 136 - Ugly Numbers

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

  9. Ugly Numbers(STL应用)

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

  10. 丑数(Ugly Numbers, UVa 136)

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

随机推荐

  1. MINA框架

    一.小程序MINA框架分为三个部分: 有 View(视图层).App Service(逻辑层)和 Natice(系统层). 1.View(视图层) 视图层包含了小程序多个页面.每个页面都有WXML文件 ...

  2. 是谁的简历上全是秒杀商城和RPC啊?

    是不是还在苦于自己简历上的项目离不开商城.RPC.秒杀.论坛.外卖.点评等等烂大街的项目?是不是翻遍全网再很难找到一个既有含金量又能看得懂的项目?那么现在就不用找了,下面这个项目一定适合你! 高性能短 ...

  3. 华企盾DSC在苹果电脑上申请审批没有通知

    由于系统通知这里没有允许DSC通知,开启后即可.系统偏好设置-通知与专注模式-通知 ​

  4. 【C++】【图像处理】形态学处理(腐蚀、膨胀)算法解析(以.raw格式的图像为基础进行图像处理、gray levels:256)

    1 void erosion(BYTE* image, int w, int h, BYTE* outImg) 2 { 3 int rept; 4 //腐蚀 5 memcpy(outImg, imag ...

  5. 持续集成Jenkins

    一.简单慨念 持续集成(Continuous integration,简称 CI),随着近几年的发展,持续集成在项目中 得到了广泛的推广和应用. 软件集成就是用一种较好的方式,使多种软件的功能集成到一 ...

  6. [CD随身听] 1984年~2005年索尼全系列Discman+CD_WALKMAN珍贵资料

    文章转载自:家电论坛https://jdbbs.com(由网友xieminjie整理提供) https://jdbbs.com/forum.php?mod=viewthread&tid=295 ...

  7. SQL Server系列:系统函数之日期和时间函数

    1.current_timestamp :获取数据库系统时间戳 --获取数据库系统时间戳 select current_timestamp go 2.getdate() :获取数据库系统时间戳 --获 ...

  8. 如何使用loki查询日志中大于某一数字的值的日志

    简介 loki是一款轻量级的日志收集中间件,比elk体系占用的内存更小,采用go语言开发,可以利用grafana来查询loki中存储的日志,loki存储日志只对提前预设的标签做索引,所以日志存储空间占 ...

  9. 十八般武艺玩转GaussDB(DWS)性能调优(二):坏味道SQL识别

    摘要:那些会导致执行效率低下的SQL语句及其执行方式,我们称之为SQL中的"坏味道". ◆ 什么是SQL中的坏味道 SQL语言是关系型数据库(RDB)的标准语言,其作用是将使用者的 ...

  10. 数仓集群管理:单节点故障RTO机制分析

    摘要:大规模分布式系统中的故障无法避免.发生单点故障时,集群状态和业务是如何恢复的? 本文分享自华为云社区<GaussDB (DWS) 集群管理系列:单节点故障RTO机制分析(集群状态恢复篇)& ...