Codeforces Round #379 (Div. 2) A. Anton and Danik

http://codeforces.com/problemset/problem/734/A

题意:2人进行比赛,告诉你每一场谁获胜。统计谁赢了

一般会用2个来计数,A赢几场和D赢几场,但其实没必要。
A-D等于A相对D赢的场次。A赢++否则–。

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <bits/stdc++.h>
using namespace std;

int main() {
int n;
string s;
cin >> n >> s;
int A = 0;
forn(i, n) {
if (s[i] == 'A') A++;
else A--;
}
if (A > 0) {
cout << "Anton" << endl;
} else if (0 > A) {
cout << "Danik" << endl;
} else {
cout << "Friendship" << endl;
}
return 0;
};