A

Vasya studies music.He has learned lots of interesting stuff. For example, he knows that there are 12 notes: C, C#, D, D#, E, F, F#, G, G#, A, B, H. He also knows that the notes are repeated cyclically: after H goes C again, and before C stands H. We will consider the C note in the row's beginning and the C note after the H similar and we will identify them with each other. The distance between the notes along the musical scale is measured in tones: between two consecutive notes there's exactly one semitone, that is, 0.5 tone. The distance is taken from the lowest tone to the uppest one, that is, the distance between C and E is 4 semitones and between E and C is 8 semitones

Vasya also knows what a chord is. A chord is an unordered set of no less than three notes. However, for now Vasya only works with triads, that is with the chords that consist of exactly three notes. He can already distinguish between two types of triads — major and minor.

Let's define a major triad. Let the triad consist of notes X, Y and Z. If we can order the notes so as the distance along the musical scale between X and Y equals 4 semitones and the distance between Y and Z is 3 semitones, then the triad is major. The distance between X and Z, accordingly, equals 7 semitones.

A minor triad is different in that the distance between X and Y should be 3 semitones and between Y and Z — 4 semitones.

For example, the triad "C E G" is major: between C and E are 4 semitones, and between E and G are 3 semitones. And the triplet "C# B F" is minor, because if we order the notes as "B C# F", than between B and C# will be 3 semitones, and between C# and F — 4 semitones.

Help Vasya classify the triad the teacher has given to him.

Input
The only line contains 3 space-separated notes in the above-given notation.

Output
Print "major" if the chord is major, "minor" if it is minor, and "strange" if the teacher gave Vasya some weird chord which is neither major nor minor. Vasya promises you that the answer will always be unambiguous. That is, there are no chords that are both major and minor simultaneously.
Examples
Input
C E G
Output
major
Input
C# B F
Output
minor
Input
A B H
Output
strange
题解:将输入的A B C 三种字符的下标存入一个数组中,然后由小到大排序,排序后即对应了12个音阶从左到右的顺序,看做ABC三个,所以只需判断ABC/CAB/BCA这三种是否满足3.4或4.3

#include<bits/stdc++.h>
using namespace std;
int main()
{
string ch[12]={"C","C#","D","D#","E","F","F#","G","G#","A","B","H"};
string b;
int w[5],l=0;
for(int i=0;i<3;i++)
{
cin>>b;
for(int j=0;j<12;j++)
{
if(b==ch[j])
{
w[l++]=j;
break;
}
}
}
sort(w,w+3);///排序后即对应了12个音阶从左到右的顺序,看做ABC三个,所以只需判断ABC/CAB/BCA这三种是否满足3.4或4.3
int str[3]={w[1]-w[0],w[2]-w[1],w[0]+12-w[2] };
if((str[0]==4&&str[1]==3)||(str[1]==4&&str[2]==3)||(str[2]==4&&str[0]==3))cout<<"major"<<endl;
else if((str[0]==3&&str[1]==4)||(str[1]==3&&str[2]==4)||(str[2]==3&&str[0]==4))cout<<"minor"<<endl;
else cout<<"strange"<<endl; }

B

Vasya learns to type. He has an unusual keyboard at his disposal: it is rectangular and it has n rows of keys containing m keys in each row. Besides, the keys are of two types. Some of the keys have lowercase Latin letters on them and some of the keys work like the "Shift" key on standard keyboards, that is, they make lowercase letters uppercase.

Vasya can press one or two keys with one hand. However, he can only press two keys if the Euclidean distance between the centers of the keys does not exceed x. The keys are considered as squares with a side equal to 1. There are no empty spaces between neighbouring keys.

Vasya is a very lazy boy, that's why he tries to type with one hand as he eats chips with his other one. However, it is possible that some symbol can't be typed with one hand only, because the distance between it and the closest "Shift" key is strictly larger than x. In this case he will have to use his other hand. Having typed the symbol, Vasya returns other hand back to the chips.
You are given Vasya's keyboard and the text. Count the minimum number of times Vasya will have to use the other hand.
Input

The first line contains three integers n, m, x (1 ≤ n, m ≤ 30, 1 ≤ x ≤ 50).
Next n lines contain descriptions of all the keyboard keys. Each line contains the descriptions of exactly m keys, without spaces. The letter keys are marked with the corresponding lowercase letters. The "Shift" keys are marked with the "S" symbol.
Then follow the length of the text q (1 ≤ q ≤ 5·105). The last line contains the text T, which consists of q symbols, which are uppercase and lowercase Latin letters.
Output

If Vasya can type the text, then print the minimum number of times he will have to use his other hand. Otherwise, print "-1" (without the quotes).

Examples
Input
2 2 1
ab
cd
1
A
Output
-1
Input
2 2 1
ab
cd
1
e
Output
-1
Input
2 2 1
ab
cS
5
abcBA
Output
1
Input
3 9 4
qwertyuio
asdfghjkl
SzxcvbnmS
35
TheQuIcKbRoWnFOXjummsovertHeLazYDOG
Output
2
Note
In the first sample the symbol "A" is impossible to print as there's no "Shift" key on the keyboard.

In the second sample the symbol "e" is impossible to print as there's no such key on the keyboard.

In the fourth sample the symbols "T", "G" are impossible to print with one hand. The other letters that are on the keyboard can be printed. Those symbols come up in the text twice, thus, the answer is 2.

题解:当文本中的字母在键盘中不存在时或者文本中有大写字母但不存在S键时都输出-1;

其他情况要记录键盘中字母的位置,如果存在S键则遍历计算小写字母到S的距离是否不超过x,具体看代码

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m,x;
cin>>n>>m>>x;
char s[100][100];//键盘上的字母
char b[500010];//要输入的文本
int w[100]={0},t[100]={0};
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>s[i][j];
}
}
int k=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(s[i][j]=='S')
{
k=1;//用于后面判断S键是否存在
for(int z=0;z<n;z++)
{
for(int y=0;y<m;y++)
{
if((z-i)*(z-i)+(y-j)*(y-j)<=x*x)//S键周围可以用一个手摁到的字符
{
w[s[z][y]-'a']=1;
}
}
}
}
else t[s[i][j]-'a']=1;//记录该字符存在,便于接下来检查是否存在
}
}
int q,ct=0,p=0;//ct记录下用两只手的次数
scanf("%d%s",&q,b);
for(int l=0;l<q;l++)
{
if(b[l]>='A'&&b[l]<='Z')//如果要输入大写字符
{
if(k!=1)//S键不存在时,令p=1,直接退出
{
p=1;
break;
}
else//存在S键时
{
if(w[b[l]-'A']!=0){}//要输入的字母可以用一只手完成
else if(t[b[l]-'A']==1)ct++;//要输入的字母要两只手完成且存在
else//要输入的字母不存在时
{
p=1;
break;
}
}
}
else if(t[b[l]-'a']!=1)//输入小写字母,且不存在
{
p=1;
break;
}
}
if(p==1)cout<<"-1"<<endl;
else cout<<ct<<endl;
}

C

Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence.

When Vasya has some free time, he goes to one of his girlfriends. He descends into the subway at some time, waits the first train to come and rides on it to the end of the branch to the corresponding girl. However, the trains run with different frequencies: a train goes to Dasha's direction every a minutes, but a train goes to Masha's direction every b minutes. If two trains approach at the same time, Vasya goes toward the direction with the lower frequency of going trains, that is, to the girl, to whose directions the trains go less frequently (see the note to the third sample).

We know that the trains begin to go simultaneously before Vasya appears. That is the train schedule is such that there exists a moment of time when the two trains arrive simultaneously.

Help Vasya count to which girlfriend he will go more often.

Input
The first line contains two integers a and b (a ≠ b, 1 ≤ a, b ≤ 106).

Output
Print "Dasha" if Vasya will go to Dasha more frequently, "Masha" if he will go to Masha more frequently, or "Equal" if he will go to both girlfriends with the same frequency.

Examples
Input
3 7
Output
Dasha
Input
5 3
Output
Masha
Input
2 3
Output
Equal
Note
Let's take a look at the third sample. Let the trains start to go at the zero moment of time. It is clear that the moments of the trains' arrival will be periodic with period 6. That's why it is enough to show that if Vasya descends to the subway at a moment of time inside the interval (0, 6], he will go to both girls equally often.

If he descends to the subway at a moment of time from 0 to 2, he leaves for Dasha on the train that arrives by the second minute.

If he descends to the subway at a moment of time from 2 to 3, he leaves for Masha on the train that arrives by the third minute.

If he descends to the subway at a moment of time from 3 to 4, he leaves for Dasha on the train that arrives by the fourth minute.

If he descends to the subway at a moment of time from 4 to 6, he waits for both trains to arrive by the sixth minute and goes to Masha as trains go less often in Masha's direction.

In sum Masha and Dasha get equal time — three minutes for each one, thus, Vasya will go to both girlfriends equally often.

题解:我是直接举的例子找规律做的,先去花费时间少的一方,当时间t%a==0时,Vasya去见Dasha;当t%b==0时,Vasya去见Masha;当t%a==0&&t%b==0时,Vasya去见见面次数比较少的女朋友,当a b 化简后如果相差1,则结果一样,若a<b 则为D方,若为a>b则为M

#include<bits/stdc++.h>
using namespace std;
int gcd (int a,int b)
{
int t;
while(b)
{
t=a%b;
a=b;
b=t;
}
return a;
}
int main()
{
int a,b;
cin>>a>>b;
int t=gcd(a,b);
a=a/t;
b=b/t;
//cout<<a<<" "<<b<<endl;
if(abs(a-b)==1)cout<<"Equal"<<endl;
else if(a<b)cout<<"Dasha"<<endl;
else if(a>b)cout<<"Masha"<<endl;
}

2020.12.3--vj个人赛补题的更多相关文章

  1. 2020.12.20-Codeforces Round #105补题

    B - Escape The princess is going to escape the dragon's cave, and she needs to plan it carefully. Th ...

  2. QFNU-ACM 2020.04.05个人赛补题

    A.CodeForces-124A (简单数学题) #include<cstdio> #include<algorithm> #include<iostream> ...

  3. 2020.10.30--vj个人赛补题

    D - D CodeForces - 743A Vladik is a competitive programmer. This year he is going to win the Interna ...

  4. 2020.10.23-vj个人赛补题

    B - B Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s consistin ...

  5. 2020.10.16--vj个人赛补题

    D - Drinks Choosing Old timers of Summer Informatics School can remember previous camps in which eac ...

  6. 2020.10.9--vj个人赛补题

    B - A Tide of Riverscape 题意:给出一组字符串,由'0','1',' . '组成,' . '可以换成 0或1,判断第 i  个和第 i+p 个字符是否可以不相等,如果可以则输出 ...

  7. 2020.10.17-pta天梯练习赛补题

    7-5敲笨钟 微博上有个自称"大笨钟V"的家伙,每天敲钟催促码农们爱惜身体早点睡觉.为了增加敲钟的趣味性,还会糟改几句古诗词.其糟改的方法为:去网上搜寻压"ong&quo ...

  8. 2020.11.14-pta天梯练习赛补题

    7-7 矩阵A乘以B 给定两个矩阵A和B,要求你计算它们的乘积矩阵AB.需要注意的是,只有规模匹配的矩阵才可以相乘.即若A有R​a​​行.C​a​​列,B有R​b​​行.C​b​​列,则只有C​a​​ ...

  9. 2020.11.1--pta阶梯练习赛补题

    7-5 古风排版 中国的古人写文字,是从右向左竖向排版的.本题就请你编写程序,把一段文字按古风排版. 输入格式: 输入在第一行给出一个正整数N(<),是每一列的字符数.第二行给出一个长度不超过1 ...

随机推荐

  1. C++模板简介

    模板是C++支持参数化多态的工具,使用模板可以使用户为类或者函数声明一种一般模式,使得类中的某些数据成员或者成员函数的参数.返回值取得任意类型. 模板是一种对类型进行参数化的工具: 通常有两种形式:函 ...

  2. 20210717 noip18

    考前 从小饭桌出来正好遇到雨下到最大,有伞但还是湿透了 路上看到一个猛男搏击暴风雨 到了机房收拾了半天才开始考试 ys 他们小饭桌十分明智地在小饭桌看题,雨下小了才来 考场 状态很差. 开题,一点想法 ...

  3. Robot Framework(7)- DateTime 测试库常用的关键字列表

    如果你还想从头学起Robot Framework,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1770899.html 前言 所有关键字 ...

  4. Nginx:常用基本命令与异常处理

    Nginx日志 - ./nginx-1.6.0-ems/logs/nginx.pid Nginx启动时应该使用cmd等命令行工具启动,双击启动同样会产生进程但会造成异常,判断条件是 ./nginx-1 ...

  5. 分享一则Linux系统邮件提示 /usr/local/lib/libprocesshider.so > /etc/ld.so.preload 的中病毒解决方法

    ​ 系统环境:CentOS Linux release 7.6.1810 (AltArch)                   CPU架构:ARM            最近发现生产服务器CPU占用 ...

  6. project read error(项目读取错误)

    maven的pom文件出现project read error 1,打开电脑cmd操作界面,在cmd界面找到打开出错项目的文件夹; 比如我的项目文件夹在D:\>eclipse-jee-file\ ...

  7. 【noip1998】题解:2的幂次方

    思路:设递归函数dfs(x)用于输出x的幂次方 最容易的思路:0不输出,1输出为2(0),2输出2,剩下的递归执行. 每一次递归:例如7,拆分为4+3,先拆出最大的是2的次方的数出来,输出4,再把3分 ...

  8. HCNP Routing&Switching之路由控制、路由策略和IP-Prefix List

    前文我们了解了IS-IS路由聚合和认证相关话题,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/15306645.html:今天我们来聊一聊路由控制技术中的路由策 ...

  9. Linux系列(10) - 命令搜索命令whereis与which

    whereis 只能搜索系统命令,不能搜索自己凭空创建的普通文件 命令格式: whereis [命令名] 选项: -b:只查找可执行文件 -m:只查找帮助文件 which 搜索命令所在路径及别名:不是 ...

  10. Linux系列(36) - yum命令安装(3)

    yum常用命令 查询 yum list:查询所有可用软件包列表 yum search 关键字:搜索服务器上所有和关键字相关的包 安装 yum -y install 包名 选项: -install 安装 ...