链接: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的更多相关文章

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

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

  3. Codeforces Round 561(Div 2)题解

    这是一场失败的比赛. 前三题应该是随便搞的. D有点想法,一直死磕D,一直WA.(赛后发现少减了个1……) 看E那么多人过了,猜了个结论交了真过了. 感觉这次升的不光彩……还是等GR3掉了洗掉这次把, ...

  4. Codeforces Round #561 (Div. 2) E. The LCMs Must be Large(数学)

    传送门 题意: 有 n 个商店,第 i 个商店出售正整数 ai: Dora 买了 m 天的东西,第 i 天去了 si 个不同的个商店购买了 si 个数: Dora 的对手 Swiper 在第 i 天去 ...

  5. Codeforces Round #561 (Div. 2)

    C. A Tale of Two Lands 题意: 给出 n 个数,问有多少点对(x,y)满足 |x-y| ≤ |x|,|y| ≤ |x+y|: (x,y) 和 (y,x) 表示一种答案: 题解: ...

  6. Codeforces Round #561 (Div. 2) A. Silent Classroom(贪心)

    A. Silent Classroom time limit per test1 second memory limit per test256 megabytes inputstandard inp ...

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

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

  9. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

随机推荐

  1. PHP按照比例随机

    有这样的需求,在打开链接的时候,随机(按照项目的某个属性的比例随机)跳转到指定的几个项目的某一个项目页面 比如项目A:80  项目B:20 那么跳转到项目A 的比例为80%,项目B的比例为20% 那么 ...

  2. python二进制数据

    一直以来对python的二进制数据搞不清楚. 一.二进制显示格式与实际存储值区别 1.二进制数据在python中以字节(bytes)类型和字节数组类型(bytearray)保存着,前者数据固定,后者不 ...

  3. star score

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...

  4. ACM学习历程—HDU1028 Ignatius and the Princess(组合数学)

    Ignatius and the Princess Description        "Well, it seems the first problem is too easy. I w ...

  5. POJ2186(有向图缩点)

    Popular Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 28379   Accepted: 11488 De ...

  6. navicat 关于orcale新建表空间,用户和权限分配

    图文教程,直观, 上面连接数据库 下面创建表空间 建表空间的设置 表空间名的设置 新建用户 填写用户名,选择默认表空间 成员属性德设置,这里因为是自己用,所以选择最大权限,其他的权限这是需要专业的了 ...

  7. Hibernate错误:javax/persistence/EntityListeners

    1. 原文地址:http://heavengate.blog.163.com/blog/static/20238105320127291018026/ 错误信息: hibernate:javax/pe ...

  8. POJ-3050

    Hopscotch Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4385   Accepted: 2924 Descrip ...

  9. Matcher的group()/group(int group)/groupCount()用法介绍

    直接上代码: package com.dajiangtai.djt_spider.util; import java.util.regex.Matcher;import java.util.regex ...

  10. Laravel框架中使用邮件发送功能

    这里是演示的用户注册之后,进行邮件激活的功能. 点击注册之后,系统会自动发送一个份邮件到注册者的邮箱,注册者点击链接激活账号. 先配置laravel中的(.env)文件 MAIL_DRIVER=smt ...