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不是,因 ...
随机推荐
- MySQL-char与 varchar 的区别?
版权声明:原创作品,谢绝转载!否则将追究法律责任. ----- 作者:kirin 1.共同点: 都是字符串类型 2.不同点: ①.char类型是定长数据类型.,对于数据插入的速度比较块,在有大量插入需 ...
- Access denied for user ‘root‘@‘localhost‘ (using password:YES)解决方法
修改jdbc.properties文件的密码
- Tomcat 配合虚拟线程,一种新的编程体验
Java 21 在今年早些时候的 9 月 19 日就正式发布,并开始正式引入虚拟线程,但是作为 Java 开发生态中老大哥 Spring 并没有立即跟进,而是在等待了两个月后的 11 月 29 日,伴 ...
- 虚拟机运行Hadoop | 各种问题解决的心路历程
ps:完成大数据技术实验报告的过程,出项各种稀奇古怪的问题.(知道这叫什么吗?经济基础决定上层建筑,我当时配置可能留下了一堆隐患,总之如果有同样的问题,希望可以帮到你) 一.虚拟机网络连接不通的各种情 ...
- springboot下添加全局异常处理和自定义异常处理
前言 在spring项目中,优雅处理异常,好处是可以将系统产生的全部异常统一捕获处理,自定义的异常也由全局异常来捕获,如果涉及到validator参数校验器使用全局异常捕获也是较为方便. 相关代码: ...
- [USACO2007NOVS] Best Cow Line S
题目描述 Farmer John 打算带领 \(N\)(\(1 \leq N \leq 2\,000\))头奶牛参加一年一度的"全美农场主大奖赛".在这场比赛中,每个参赛者必须让他 ...
- net8获取泛微token以及访问api示例
工作中涉及到调用泛微的场景,官方的示例又臭又长,抽空用NET8简化了写法,为了简化http访问,用了Flurl.Http这个库.在座各位大佬,我们直接就看代码了 using System.Secu ...
- C++ Qt开发:标准Dialog对话框组件
Qt 是一个跨平台C++图形界面开发库,利用Qt可以快速开发跨平台窗体应用程序,在Qt中我们可以通过拖拽的方式将不同组件放到指定的位置,实现图形化开发极大的方便了开发效率,本章将重点介绍标准对话框QI ...
- Selenium基本使用、过检测
import time from selenium import webdriver from selenium.webdriver.chrome.service import Service as ...
- Go 泛型之类型参数
Go 泛型之类型参数 一.Go 的泛型与其他主流编程语言的泛型差异 Go泛型和其他支持泛型的主流编程语言之间的泛型设计与实现存在差异一样,Go 的泛型与其他主流编程语言的泛型也是不同的.我们先看一下 ...