【77.39%】【codeforces 734A】Anton and Danik
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Anton likes to play chess, and so does his friend Danik.
Once they have played n games in a row. For each game it’s known who was the winner — Anton or Danik. None of the games ended with a tie.
Now Anton wonders, who won more games, he or Danik? Help him determine this.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of games played.
The second line contains a string s, consisting of n uppercase English letters ‘A’ and ‘D’ — the outcome of each of the games. The i-th character of the string is equal to ‘A’ if the Anton won the i-th game and ‘D’ if Danik won the i-th game.
Output
If Anton won more games than Danik, print “Anton” (without quotes) in the only line of the output.
If Danik won more games than Anton, print “Danik” (without quotes) in the only line of the output.
If Anton and Danik won the same number of games, print “Friendship” (without quotes).
Examples
input
6
ADAAAA
output
Anton
input
7
DDDAADA
output
Danik
input
6
DADADA
output
Friendship
Note
In the first sample, Anton won 6 games, while Danik — only 1. Hence, the answer is “Anton”.
In the second sample, Anton won 3 games and Danik won 4 games, so the answer is “Danik”.
In the third sample, both Anton and Danik won 3 games and the answer is “Friendship”.
【题目链接】:http://codeforces.com/contest/734/problem/A
【题解】
统计一下两个字符出现的次数;
比较大小即可;
好水的题。。
不,这已经水破天际了;
ps:D题手慢了TAT,捶胸顿足状。
【完整代码】
#include <bits/stdc++.h>
using namespace std;
int a[2],n;
int main()
{
cin >> n;
string s;
cin >> s;
for (int i = 0;i <= n-1;i ++)
if (s[i] == 'A')
a[0]++;
else
if (s[i] == 'D')
a[1] ++;
if (a[0] == a[1])
puts("Friendship");
else
if (a[0] > a[1])
puts("Anton");
else
puts("Danik");
return 0;
}
【77.39%】【codeforces 734A】Anton and Danik的更多相关文章
- 【35.02%】【codeforces 734A】Vladik and flights
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【 BowWow and the Timetable CodeForces - 1204A 】【思维】
题目链接 可以发现 十进制4 对应 二进制100 十进制16 对应 二进制10000 十进制64 对应 二进制1000000 可以发现每多两个零,4的次幂就增加1. 用string读入题目给定的二进制 ...
- 【19.77%】【codeforces 570D】Tree Requests
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【39.66%】【codeforces 740C】Alyona and mex
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【23.39%】【codeforces 558C】Amr and Chemistry
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【77.78%】【codeforces 625C】K-special Tables
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- 【39.29%】【codeforces 552E】Vanya and Brackets
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【13.77%】【codeforces 734C】Anton and Making Potions
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 750D】New Year and Fireworks
time limit per test2.5 seconds memory limit per test256 megabytes inputstandard input outputstandard ...
随机推荐
- ArcGIS在线帮助的使用指南
一直感觉ArcGIS的在线帮助就是鸡肋,没想到网络常见的所谓的高大上的博文,也不过是对GIS 在线帮助的拷贝,或者简单修改而已.其实ArcGIS的在线帮助包含了以下几个很好用的模块: 备注 ArcGI ...
- [D3] Animate Transitions in D3 v4
D3 makes it easy to add meaningful animations to your data visualizations. Whether it’s fading in ne ...
- 通达OA二次开发 对通达2015版微信查询用户信息模块升级开发(图文)
OA提供对微信的支持这一点做的很好,用户使用起来也更方便了. 而当中的个别功能还有待完好,比现在天要说的这个微信查询用户信息模块. 升级前的用法:输入@+用户中文名.而且要求全然匹配,然而在实际使用中 ...
- Day1:注释
一.注释方法 1.单行注释用#,本行#号后的内容为注释内容,不执行 2.多行用三个单引号或三个双引号标注,中间内容为注释,不执行 二.其他相关内容 三个引号中的内容还可以当作字符串赋值给变量,可以同时 ...
- SQL Server 中计算农历
1.建一表,放初始化资料 因为农历的日期,是由天文学家推算出来的,到现在只有到2049年的,以后的有了还可以加入! CREATE TABLE SolarData ( yearId int no ...
- 【Codeforces Round #299 (Div. 2) D】Tavas and Malekas
[链接] 我是链接,点我呀:) [题意] 给你n个位置,然后让你从某些位置开始的|p|个位置,填上p这个字符串. 问你填的时候是否会发生冲突->输出0 否则输出最终n个位置组成的可能的字符串的总 ...
- DOS 命令forfiles
forfiles /p E:/dbbackup/diff /s /m *.* /d -14 /c "cmd /c del @file" forfiles: /p 指定的路径 /s ...
- UIBarButtonItem使用
1 self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBar ...
- [RxJS] ReplaySubject with buffer
A BehaviorSubject can remember the latest value emitted, but what if we wanted Observer B to see all ...
- md5解密猜想
md5解密猜想 一.总结 一句话总结:可以用有技巧性(常用密码,相关信息)的暴力破解. 二.md5解密猜想 1.暴力破解 其实md5也是由那些常用的字符串组组成的32位密文,所以可以把那些常用字符串( ...