三个题,各位大佬别喷我,我很菜
A Silent Classroom
There are n students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinct students whose name starts with the same letter will be chatty if they are put in the same classroom (because they must have a lot in common). Let x be the number of such pairs of students in a split. Pairs (a,b) and (b,a) are the same and counted only once.

For example, if there are 6 students: “olivia”, “jacob”, “tanya”, “jack”, “oliver” and “jessica”, then:

splitting into two classrooms (“jack”, “jacob”, “jessica”, “tanya”) and (“olivia”, “oliver”) will give x=4 (3 chatting pairs in the first classroom, 1 chatting pair in the second classroom),
splitting into two classrooms (“jack”, “tanya”, “olivia”) and (“jessica”, “oliver”, “jacob”) will give x=1 (0 chatting pairs in the first classroom, 1 chatting pair in the second classroom).
You are given the list of the n names. What is the minimum x we can obtain by splitting the students into classrooms?

Note that it is valid to place all of the students in one of the classrooms, leaving the other one empty.

Input
The first line contains a single integer n (1≤n≤100) — the number of students.

After this n lines follow.

The i-th line contains the name of the i-th student.

It is guaranteed each name is a string of lowercase English letters of length at most 20. Note that multiple students may share the same name.

Output
The output must consist of a single integer x — the minimum possible number of chatty pairs.

Examples
Input
4
jorge
jose
oscar
jerry
Output
1
Input
7
kambei
gorobei
shichiroji
kyuzo
heihachi
katsushiro
kikuchiyo
Output
2
Input
5
mike
mike
mike
mike
mike
Output
4
Note
In the first sample the minimum number of pairs is 1. This can be achieved, for example, by putting everyone except jose in one classroom, and jose in the other, so jorge and jerry form the only chatty pair.

In the second sample the minimum number of pairs is 2. This can be achieved, for example, by putting kambei, gorobei, shichiroji and kyuzo in one room and putting heihachi, katsushiro and kikuchiyo in the other room. In this case the two pairs are kambei and kyuzo, and katsushiro and kikuchiyo.

In the third sample the minimum number of pairs is 4. This can be achieved by placing three of the students named mike in one classroom and the other two students in another classroom. Thus there will be three chatty pairs in one classroom and one chatty pair in the other classroom.
只有首字母相同的才会说话,问最小有多少个人能互相说话。
最小的时候就是一个房间里有一半人。。。
代码如下:

#include<bits/stdc++.h>
#define ll long long
using namespace std;int n;
map<char,int>mp;
string s;int main()
{while(scanf("%d",&n)!=EOF){int cnt=1;mp.clear();for(int i=0;i<n;i++){cin>>s;mp[s[0]]++;}int sum=0;for(map<char,int> ::iterator it=mp.begin();it!=mp.end();it++){ll x=it->second/2;ll y;if(x*2!=it->second) y=x+1;else y=x;sum+=(x)*(x-1)/2+y*(y-1)/2;}cout<<sum<<endl;}
}

B All the Vowels Please
Tom loves vowels, and he likes long words with many vowels. His favorite words are vowelly words. We say a word of length k is vowelly if there are positive integers n and m such that n⋅m=k and when the word is written by using n rows and m 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 k and you must either print a vowelly word of length k or print −1 if no such word exists.

In this problem the vowels of the English alphabet are ‘a’, ‘e’, ‘i’, ‘o’ ,‘u’.

Input
Input consists of a single line containing the integer k (1≤k≤104) — the required length.

Output
The output must consist of a single line, consisting of a vowelly word of length k consisting of lowercase English letters if it exists or −1 if it does not.

If there are multiple possible words, you may output any of them.

Examples
Input
7
Output
-1
Input
36
Output
agoeuioaeiruuimaeoieauoweouoiaouimae
Note
In the second example, the word “agoeuioaeiruuimaeoieauoweouoiaouimae” can be arranged into the following 6×6 grid:

It is easy to verify that every row and every column contain all the vowels.
构造,每一行每一列都要有5个元音字母,嘤嘤嘤,一开始理解错了wa了几发
代码如下:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;int n;int main()
{while(~scanf("%d",&n)){int pos;int flag=0;for(int i=5;i<=sqrt(n);i++){if(n%i==0){if(i>=5&&n/i>=5){flag=1;pos=i;break;}}}if(flag==0){cout<<"-1"<<endl;continue;}string s[6];s[1]="aeiou";s[2]="eaoui";s[3]="iuaeo";s[4]="oiuae";s[5]="uoeia";for(int i=1;i<=n/pos;i++){cout<<s[(i%5)?i%5:5];for(int j=0;j<pos-5;j++){if(j==0) cout<<s[(i%5)?i%5:5][1];else cout<<s[(i%5)?i%5:5][(j%4)+1];}//cout<<endl;}cout<<endl;}
}
/*
aoeui
oaeiu
uiaeo
ieuoweouoiaouimae
*/

C A Tale of Two Lands
The legend of the foundation of Vectorland talks of two integers x and y. Centuries ago, the array king placed two markers at points |x| and |y| on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points |x−y| and |x+y| and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland.

Here |z| denotes the absolute value of z.

Now, Jose is stuck on a question of his history exam: “What are the values of x and y?” Jose doesn’t know the answer, but he believes he has narrowed the possible answers down to n integers a1,a2,…,an. Now, he wants to know the number of unordered pairs formed by two different elements from these n integers such that the legend could be true if x and y were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.

Input
The first line contains a single integer n (2≤n≤2⋅105) — the number of choices.

The second line contains n pairwise distinct integers a1,a2,…,an (−109≤ai≤109) — the choices Jose is considering.

Output
Print a single integer number — the number of unordered pairs {x,y} formed by different numbers from Jose’s choices that could make the legend true.

Examples
Input
3
2 5 -3
Output
2
Input
2
3 6
Output
1
Note
Consider the first sample. For the pair {2,5}, the situation looks as follows, with the Arrayland markers at |2|=2 and |5|=5, while the Vectorland markers are located at |2−5|=3 and |2+5|=7:

The legend is not true in this case, because the interval [2,3] is not conquered by Vectorland. For the pair {5,−3} the situation looks as follows, with Arrayland consisting of the interval [3,5] and Vectorland consisting of the interval [2,8]:

As Vectorland completely contains Arrayland, the legend is true. It can also be shown that the legend is true for the pair {2,−3}, for a total of two pairs.

In the second sample, the only pair is {3,6}, and the situation looks as follows:

Note that even though Arrayland and Vectorland share 3 as endpoint, we still consider Arrayland to be completely inside of Vectorland.

咋说嘞,因为最后都是绝对值,都是正数。如果x<y,那么最后的式子就可以化为y-x<x<y<y+x,只有y-x<x这个式子需要判定条件,就是y<2*x。这样的话,我们给数组排个序,二分去找y,最后把结果加起来就好了。
代码如下:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#define ll long long
using namespace std;const int maxx=2e5+100;
ll a[maxx];
int n;int main()
{while(scanf("%d",&n)!=EOF){for(int i=0;i<n;i++){scanf("%I64d",&a[i]);a[i]=abs(a[i]);//s.insert(abs(a[i]));}int cnt=0;//for(set<int> ::iterator it=s.begin();it!=s.end();it++) a[cnt++]=*it;sort(a,a+n);ll sum=0;for(int i=0;i<n;i++){int pos=upper_bound(a,a+n,a[i]*2ll)-a;sum+=pos-i-1;}cout<<sum<<endl;}
}

努力加油a啊,(o)/~

Codeforces Round #561 (Div. 2)ABC相关推荐

  1. Educational Codeforces Round 112(Div.2) ABC题解

    D题好像可以做一做,挖个坑以后做好了来填(doge Educational Codeforces Round 112(Div.2) 题目列表 1.A 2.B 3.C 1.A 原题链接 题目大意 有三种 ...

  2. Codeforces Round #783 (Div. 2)和Codeforces Round #784 (Div. 4)---- ABC | ABCDEF

    目录 Codeforces Round #783 (Div. 2) A B C Codeforces Round #784 (Div. 4) A B C D E F Codeforces Round ...

  3. Codeforces Round #561 (Div. 2)-E. The LCMs Must be Large

    地址:https://codeforces.com/contest/1166/problem/E 思路:比赛时,D,E两题都不会写,然后抱着试一试的态度对E分析,对于第i天,若其他天与该天是没有重合的 ...

  4. Codeforces Round #712 (Div. 2)-ABC

    A. Déjà Vu A palindrome is a string that reads the same backward as forward. For example, the string ...

  5. Codeforces Round #783 (Div. 2) ABC

    自从上个月得了麦粒肿,又遇上入D的一系列麻烦事儿,心态爆炸,状态开始摆烂,摆完蓝桥杯,摆完昆明站,终于在这几天感觉状态逐渐好转... 冲冲冲! ​​​​​​​​​​​Problem - A - Cod ...

  6. Codeforces Round #295 (Div. 2) ABC

    A - Pangram :判断一个字符串中有木有出现过26个字母,不论大小写,有YES没有NO #include <map> #include <set> #include & ...

  7. CodeCraft-21 and Codeforces Round #711 (Div. 2)ABC题解

    A题,至少能找到个gcd=2gcd=2gcd=2的,只要222个都是偶数就行 #include<bits/stdc++.h> using namespace std; typedef lo ...

  8. Codeforces Round #698 (Div. 2)(A ~ F)6题全,超高质量题解)【每日亿题】2021/2/4

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 [每日亿题]Codeforces Round #698 (Div. 2)(A ~ F)6题全,超 ...

  9. Codeforces Round #225 (Div. 1) E. Vowels 容斥 + sosdp

    传送门 文章目录 题意: 思路: 题意: 给你nnn个长度为333的串,串的每个字母都在a−za-za−z范围内,定义一个串合法当且仅当这个串中含有至少一个元音字母.现在他忘记了元音字母都有那几个,显 ...

最新文章

  1. kibana操作elasticsearch:match匹配查询(最小匹配参数查询)
  2. 仿京东左侧菜单弹出html代码,相仿京东左侧菜单
  3. Ubuntu 配置swftools(Ubuntu14.04)
  4. spring MVC 的MultipartFile转File读取
  5. Excel2013数据透视表、Power View中的钻取
  6. MatLab基本知识学习 详细!
  7. 十二届蓝桥杯c++A组答案
  8. OS X Eagle Peak:据说这是 Mac 新系统名称
  9. matlab入门(适合初学者)
  10. oracle中 greatest、east、coalesce
  11. HDU 4125 Moles 段树+KMP
  12. 限幅二极管基础知识详解
  13. More Effective C++读书笔记
  14. Cadence的版图绘制、DRC、LVS、PEX-以反相器为例
  15. Android FaceBook登录接入--散列密钥获取
  16. 三维动画制作软件测试指标,102092三维动画软件基础课程标准已审核.doc
  17. Django 快速入门课程「搭建个人博客」
  18. 广州工商学院计算机答辩,电子信息工程系2019届毕业生论文答辩新闻稿
  19. 3dmax和python做3d动画_ThingJS问答录 | 三维动画师和程序员的职业前景 3D 可视化
  20. CLRS 6.3建堆

热门文章

  1. ios基础考试题1,实现按钮点击改变位置和图片的透明度和动画的使用
  2. hashmap中的key是有序的么_HashMap?面试?我是谁?我在哪
  3. python自动点击网页按钮_Python+Selenium使用(二)- 自动点击下一页
  4. 关于python_关于 Python
  5. Android开发之EditText输入显示文字hint大小设置
  6. argo 现水下永动机器人_现水下永动机器人 水下永动机器人有什么作用?
  7. 安卓下载保存到本地(一)
  8. JAVA-基础(查找文件夹内文件)
  9. JavaScript30秒, 从入门到放弃之Array(三)
  10. MyGeneration学习笔记(5) :在Web Service中使用dOOdad(中)