Codeforces 1326A Bad Ugly Numbers (思维)
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 (思维)的更多相关文章
- codeforces 1236 A. Bad Ugly Numbers
A. Bad Ugly Numbers time limit per test 1 second memory limit per test 256 megabytes input standard ...
- [codeforces 55]D. Beautiful numbers
[codeforces 55]D. Beautiful numbers 试题描述 Volodya is an odd boy and his taste is strange as well. It ...
- [POJ1338]Ugly Numbers
[POJ1338]Ugly Numbers 试题描述 Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequ ...
- Ugly Numbers
Ugly Numbers Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 21918 Accepted: 9788 Descrip ...
- poj 1338 Ugly Numbers(丑数模拟)
转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063? viewmode=contents 题目链接:id=1338&q ...
- 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 ...
- 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, ...
- 136 - Ugly Numbers
Ugly Numbers Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3 ...
- Ugly Numbers(STL应用)
题目链接:http://poj.org/problem?id=1338 Ugly Numbers Time Limit: 1000MS Memory Limit: 10000K Total Sub ...
- 丑数(Ugly Numbers, UVa 136)
丑数(Ugly Numbers, UVa 136) 题目描述 我们把只包含因子2.3和5的数称作丑数(Ugly Number).求按从小到大的顺序的第1500个丑数.例如6.8都是丑数,但14不是,因 ...
随机推荐
- Shell必备三剑客
Top 目录 Sed--三剑客之一 基本格式 选项及含义 命令flags标记及功能 支持正则表达式, 扩展正则表达式 高级命令 命令格式 注意: 命令示例 字符串替换----'s' 行内容替换--'c ...
- MySQL Group by 优化查询
Group by 未加索引 使用的是临时表,加文件排序(数据量小用内存排序) 加个索引(一般是联合索引) 注意:这里加的索引一般不会仅仅是group by后面的字段索引(大多数多少条件是一个以该字 ...
- 中间件IIS监控指标、配置和Windbg调试分析
1. 关键性能计数器指标 a. Web服务(W3SVC)性能计数器 当前连接数(Current Connections):显示当前所有HTTP连接的数量.过高的数值可能表明网站流量过大或连接无法及时释 ...
- css零散笔记——修改input样式input:-internal-autofill-selected背景色
闲聊: 小颖项目中的登录页需将 input 背景色设为透明,小颖将 input 的背景色设置后,发现表单自动填充后还是会有背景色,然后发现 浏览器 自带了背景色: 效果图: ...
- python中的post请求
用python来验证接口正确性,主要流程有4步: 1 设置url 2 设置消息头 3 设置消息体 4 获取响应 5 解析相应 6 验证数据 Content-Type的格式有四种:分别是applicat ...
- 【UniApp】-uni-app-扩展组件
前言 好,经过上个章节的介绍完毕之后,了解了一下 uni-app-内置组件 那么了解完了uni-app-内置组件之后,这篇文章来给大家介绍一下 UniApp 中的扩展组件 首先不管三七二十一,先来新建 ...
- 数据库的连接用Java
第一步注册驱动 Class.forName("com.mysql.cj.jdbc.Driver"); 第二步创建用户密码,和具体的url static String name = ...
- 【2016】CloneCD和IsoBuster配合使用以提取VCD中的文件
**笔记记录于:2016-11-24 ** 本文章仅供用于技术研究用途,请勿利用文章内容操作用于违反法律的事情. 起因: 公司老总让我提取下VCD中的文件以备份下,但是把光碟放进DVD光驱中发现只有几 ...
- 万界星空科技电子电器装配行业云MES解决方案
电子电器装配属于劳动密集型.科技含量较高的行业,产品零部件种类繁多,生产组装困难,生产过程存在盲点,同时也决定了生产流水线多且对自动化水平要求较高. 万界星空科技提供的电子行业解决方案,从仓储管理.生 ...
- STM32CubeMX教程3 GPIO输入 - 按键响应
1.准备材料 开发板(STM32F407G-DISC1) ST-LINK/V2驱动 STM32CubeMX软件(Version 6.10.0) keil µVision5 IDE(MDK-Arm) 2 ...