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 ;
}
最新文章
- 模拟ajax的同异步
- ubuntu12.04安装搜狗输入法和配置
- book
- WinFrom 登录窗体 密码保存效果
- List分页 参考
- java socket解析和发送二进制报文工具(附java和C++转化问题)
- 生鲜配送管理系统_升鲜宝V2.0 供应商协同系统设计思想及设计效果展现(一)
- C语言判断水仙花数
- JavaScript实现全屏显示
- spring(三、spring中的eheche缓存、redis使用)
- Vue.js入门系列(一)
- MFC函数—— CFrameWnd::OnCreateClient
- Tree Cutting (Hard Version) CodeForces - 1118F2 (树形DP,计数)
- opencv-python教程学习系列7-opencv图像基本操作
- homework 补第三题
- jzoj5928
- 在Linux中安装Oracle(较详细图解)
- mysql5.7 初始化启动
- Spark应用程序运行的日志存在哪里(转)
- 湘潭邀请赛 2018 E From Tree to Graph