A. Anton and Danik
Problem Link: [Codeforces 734A##link##]
- [tab]
- C++
#include <bits/stdc++.h> #include <string> typedef long long ll; using namespace std; int main() { int n; cin>>n; string s; cin>>s; int i=0,a=0,b=0; while(i<n) { if(s[i]=='A') a++; else b++; i++; } if(a>b) cout<<"Anton"; else if(a<b) cout<<"Danik"; else cout<<"Friendship"; return 0; }
- Python 3
I=input n=int(I()) a=I().count('A')*2 print([['Friendship','Danik'][a<n],'Anton'][a>n])
- JAVA
import java.util.*; public class cf { static Scanner input = new Scanner(System.in); public static void main(String[] args) { int n = input.nextInt(); input.nextLine(); String s = input.nextLine(); int countD = 0; int countA = 0; for(int i=0;i<s.length();i++) { if(s.charAt(i)=='D') countD++; else countA++; } if(countD == countA) System.out.println("Friendship"); else if (countD > countA) System.out.println("Danik"); else System.out.println("Anton"); } }