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不是,因 ...
随机推荐
- Java数组最常用操作方法(Arrays类)
最近在写代码的过程中发现我们很多地方都会处理数组,有时只是模糊的记得有API可以调用,每次都查文档很是费事儿,适当的总结希望提高开发速度 一.申明数组 数组的申明十分简单也十分的基础,注意第三种申明方 ...
- [Python急救站]火车购票程序
火车购票程序 如果要一直执行程序,加个while循环即可.要是要智能判断月份,可以通过调取当前时间进行判断即可. print(""" 1.每年的1-3月和7-9月凭学生证 ...
- python原生数据类型(上)
# 查看数据 print('hello world') # 查看数据类型 type('hello world') hello world str 1 数据类型定义 1.1 不可变数据类型 # 数值 # ...
- idea用不了 idea.bat文件闪退
由于idea的智能,在破解之后会留下一些问题,根据网上搜出来的解决办法. 1.C:\Users\dell\AppData\Roaming\JetBrains\IntelliJIdea2022.2 在这 ...
- out.print()
在学习过程中发现跟着视频打out.print报错 查阅资料知道 新建Java工程时,应选择Java Enterprise而非Java里的webapplication(Java Enterprise会自 ...
- 年度盘点,四年的精华合集「GitHub 热点速览」
今年是 GPT 年,无论是 GitHub 还是朋友圈还是技术平台,即便你不关心 GPT 的发展情况,同大模型.AI 相关的项目总能进入你的信息流.到这期为止,热度速览也连载了四年,从一开始习惯看 Gi ...
- 【Python】【OpenCV】边缘检测和创建自定义核
对于使用OpenCV已有的算子,我们还可以自定义卷积核以达到不同的效果. filters.py 1 import cv2 2 import numpy 3 4 """ 定 ...
- modeless dialog in html
<!DOCTYPE html> <html lang="zh_CN"> <head> <meta charset="UTF-8& ...
- IntelliJ IDEA官方宣布中文汉化包正式发布-intellijidea-guan-fang-xuan-bu-zhong-wen-han-hua-bao-zheng-shi-fa-bu
title: IntelliJ IDEA官方宣布中文汉化包正式发布 date: 2021-07-27 16:42:21.823 updated: 2021-12-26 17:43:12.204 url ...
- Kernel Memory 入门系列:异步管道
Kernel Memory 入门系列:异步管道 前面所介绍的处理流程都是基于同步管道的,即文档导入的时候,会等到文档处理完成之后才会返回. 但是在实际的应用中,文档很多,而且文档的处理时间也不确定,如 ...