Codeforces Round #561 (Div. 2) B. All the Vowels Please
链接:https://codeforces.com/contest/1166/problem/B
题意:
Tom loves vowels, and he likes long words with many vowels. His favorite words are vowelly words. We say a word of length kk is vowelly if there are positive integers nn and mm such that n⋅m=kn⋅m=k and when the word is written by using nn rows and mm columns (the first row is filled first, then the second and so on, with each row filled from left to right), every vowel of the English alphabet appears at least once in every row and every column.
You are given an integer kk and you must either print a vowelly word of length kk or print −1−1 if no such word exists.
In this problem the vowels of the English alphabet are 'a', 'e', 'i', 'o' ,'u'.
思路:
先求出k的所有因子,如果能找到两个大于等于5的因子,就挨个往矩阵里填因子,
否则就-1.
代码:
#include <bits/stdc++.h>
using namespace std; typedef long long LL; char s[5] = {'a', 'e', 'i', 'o', 'u'}; int main()
{
int n;
cin >> n;
set<int> yinzi;
for (int i = 1;i*i <= n;i++)
if (n%i == 0)
yinzi.insert(i), yinzi.insert(n/i);
for (auto it = yinzi.begin();it != yinzi.end();++it)
{
if ((*it) >= 5 && n/(*it) >= 5)
{
for (int i = 0;i < (*it);i++)
{
int pos = i;
for (int j = 1;j <= n/(*it);j++)
cout << s[(pos++)%5];
}
return 0;
}
}
cout << -1 << endl; return 0;
}
Codeforces Round #561 (Div. 2) B. All the Vowels Please的更多相关文章
- Codeforces Round #561 (Div. 2) C. A Tale of Two Lands
链接:https://codeforces.com/contest/1166/problem/C 题意: The legend of the foundation of Vectorland talk ...
- Codeforces Round #561 (Div. 2) A. Silent Classroom
链接:https://codeforces.com/contest/1166/problem/A 题意: There are nn students in the first grade of Nlo ...
- Codeforces Round 561(Div 2)题解
这是一场失败的比赛. 前三题应该是随便搞的. D有点想法,一直死磕D,一直WA.(赛后发现少减了个1……) 看E那么多人过了,猜了个结论交了真过了. 感觉这次升的不光彩……还是等GR3掉了洗掉这次把, ...
- Codeforces Round #561 (Div. 2) E. The LCMs Must be Large(数学)
传送门 题意: 有 n 个商店,第 i 个商店出售正整数 ai: Dora 买了 m 天的东西,第 i 天去了 si 个不同的个商店购买了 si 个数: Dora 的对手 Swiper 在第 i 天去 ...
- Codeforces Round #561 (Div. 2)
C. A Tale of Two Lands 题意: 给出 n 个数,问有多少点对(x,y)满足 |x-y| ≤ |x|,|y| ≤ |x+y|: (x,y) 和 (y,x) 表示一种答案: 题解: ...
- Codeforces Round #561 (Div. 2) A. Silent Classroom(贪心)
A. Silent Classroom time limit per test1 second memory limit per test256 megabytes inputstandard inp ...
- Codeforces Round #561 (Div. 2) A Tale of Two Lands 【二分】
A Tale of Two Lands 题目链接(点击) The legend of the foundation of Vectorland talks of two integers xx and ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- python读取文件后切片
from itertools import islice with open(“1.txt") as f: for a in islice(f,0,2): print(a)
- 搭建LoadRunner中的场景(四)控制器的全局设置
选择“Tools”菜单-“Options”选项打开设置窗口 1.超时设置 2.运行时设置 3.运行时文件存储设置 4.路径翻译表 路径翻译表是一种映射,将控制器上的文件路径转换为远程主机上的文件路径. ...
- Facebook的实时流处理技术——Scuba是Facebook的一个非常快速、分布式的内存数据库,用于实时分析和查询
Scuba,Facebook的一个非常快速.分布式的内存数据库,用于实时分析和查询.是Facebook的回归分析代码.错误报告监控.广告收入监控和性能调试的背后主力. Facebook的实时流处理技术 ...
- [原创]java导出excel
一.需求背景 在项目开发中,经常会遇到导出Excel报表文件的情况,因为很多情况下,我们需要打印Excel报表,虽然在网页上也可以生成报表,但是打印网上里的报表是无法处理排版问题的,所以最好的方式,还 ...
- PHP实现简单爬虫-抓取网页url
<?php /** * 爬虫程序 -- 原型 * * 从给定的url获取html内容 * * @param string $url * @return string */ function _g ...
- Python: scikit-image 图像的基本操作
这个用例说明Python 的图像基本运算 import numpy as np from skimage import data import matplotlib.pyplot as plt cam ...
- JSP 使用<%@include%>报Duplicate local variable path 错误 解决方法
错误提示:Multiple annotations found at this line:- Duplicate local variable path- Duplicate local variab ...
- ACM学习历程—HDU2222 Keywords Search(字典树)
Keywords Search Description In the modern time, Search engine came into the life of everybody like G ...
- codevs2821 天使之城
传送门 2821 天使之城 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 天使城有一个火车站,每辆火车都从A方向驶入车站 ...
- python爬虫知识点总结(一)库的安装
环境要求: 1.编程语言版本python3: 2.系统:win10; 3.浏览器:Chrome68.0.3440.75:(如果不是最新版有可能影响到程序执行) 4.chromedriver2.41 注 ...