C - Anton and Danik
Problem description
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".
解题思路:简单比较'A'和'D'出现的次数即可,水过!
AC代码:
#include<bits/stdc++.h>
using namespace std;
int n,t1=,t2=;char s[];
int main(){
cin>>n;getchar();
cin>>s;
for(int i=;s[i]!='\0';++i){
if(s[i]=='A')t1++;
else t2++;
}
if(t1<t2)cout<<"Danik"<<endl;
else if(t1>t2)cout<<"Anton"<<endl;
else cout<<"Friendship"<<endl;
return ;
}
C - Anton and Danik的更多相关文章
- Codeforces Round #379 (Div. 2) A. Anton and Danik 水题
A. Anton and Danik 题目连接: http://codeforces.com/contest/734/problem/A Description Anton likes to play ...
- 【77.39%】【codeforces 734A】Anton and Danik
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 题解 CF734A 【Anton and Danik】
本蒟蒻闲来无事刷刷水题 话说这道题,看楼下的大佬们基本都是用字符 ( char ) 来做的,那么我来介绍一下C++的优势: string ! string,也就是类型串,是C语言没有的,使用十分方便 ...
- Codeforces Round #379 (Div. 2) A B C D 水 二分 模拟
A. Anton and Danik time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #379 (Div. 2) Analyses By Team:Red & Black
A.Anton and Danik Problems: 给你长度为N的,只含'A','D'的序列,统计并输出何者出现的较多,相同为"Friendship" Analysis: lu ...
- string 的用法
上次,我在" Anton And Danik "中为大家介绍了 string 的部分用法 今天,我就再来为大家介绍一下 string 的其他用法 : ( 有可能已经讲过了,不要介意 ...
- Codeforces Round #404 (Div. 2) C. Anton and Fairy Tale 二分
C. Anton and Fairy Tale 题目连接: http://codeforces.com/contest/785/problem/C Description Anton likes to ...
- Codeforces 734E. Anton and Tree 搜索
E. Anton and Tree time limit per test: 3 seconds memory limit per test :256 megabytes input:standard ...
- 贪心 Codeforces Round #288 (Div. 2) B. Anton and currency you all know
题目传送门 /* 题意:从前面找一个数字和末尾数字调换使得变成偶数且为最大 贪心:考虑两种情况:1. 有偶数且比末尾数字大(flag标记):2. 有偶数但都比末尾数字小(x位置标记) 仿照别人写的,再 ...
随机推荐
- Python那点事
目录 Python那点事 一. Python介绍 二. 目前python的主要领域 三.Python的运用 四. Python的发展史 Python的种类 Python那点事 相信很多小伙伴会跳过此环 ...
- 【Codeforces 1114B】Yet Another Array Partitioning Task
[链接] 我是链接,点我呀:) [题意] 让你把数组分成k个连续的部分 使得每个部分最大的m个数字的和最大 [题解] 把原数组降序排序 然后选取前m*k个数字打标记 然后对于原数组 一直贪心地取 直到 ...
- RAID级别简介
独立硬盘冗余阵列(RAID, Redundant Array of Independent Disks),旧称廉价磁盘冗余阵列(RAID, Redundant Array of Inexpensive ...
- ssh_整合总结
开场白:首先,我先帮大家整理一下思路 准备: 数据库,表,数据 jar 包准备 Hibernate 基本jar 包 C3p0 数据库连接池 Spring AOP 基本包 Spring Ioc 基本包 ...
- 一个手机图表(echarts)折线图的封装
//定义一组颜色值,按顺序取出 var colorGroup = ["#6ca3c4","#76bfa3","#ea8f7a"," ...
- 【ACM】nyoj_14_会场安排问题_201308151955
会场安排问题时间限制:3000 ms | 内存限制:65535 KB 难度:4描述 学校的小礼堂每天都会有许多活动,有时间这些活动的计划时间会发生冲突,需要选择出一些活动进行举办.小刘的工作就是安 ...
- E - Period
For each prefix of a given string S with N characters (each character has an ASCII code between 97 a ...
- 机器学习10k均值
下面介绍无监督机器学习算法,与前面分类回归不一样的是,这个不知道目标变量是什么,这个问题解决的是我们从这些样本中,我们能发现什么. 这下面主要讲述了聚类算法,跟数据挖掘中的关联挖掘中的两个主要算法. ...
- WEB开发面试题
1.HTML的全称: 2.HTML的结构: 3.经常使用标签: 4.CSS的全称: 5.CSS的作用: 6.CSS中创建Class的语法: ...
- 工作easy,赚钱非常难
李宗盛有首歌的歌词里写到:「工作是easy的,赚钱是困难的」. 乍一听感觉有点矛盾,工作的一个重要结果不就是赚钱么,为什么工作easy赚钱却难?但细致一想就恍然当中想表达的意思了. 工作的本质是出售劳 ...