Saturday, June 28, 2014

Codeforces Round #141 (Div. 2), problem: (A) Is your horseshoe on the other hoof? solution

Codeforces Round #141 (Div. 2), problem: (A) Is your horseshoe on the other hoof? : http://codeforces.com/problemset/problem/228/A

Codeforces Round #141 (Div. 2), problem: (A) Is your horseshoe on the other hoof? editorial: http://codeforces.com/blog/entry/5404

Codeforces Round #141 (Div. 2), problem: (A) Is your horseshoe on the other hoof? solution: http://ideone.com/a5XhpJ

#include <iostream>
#include <cstdio>
#include <map>
using namespace std;

int main() {
    int b=0, cnt=0;
    map <int, int> a;
    for(int i=0; i<4; i++) {
        scanf("%d", &b);
        a[b]++;
    }
    for(map <int, int>::iterator ii=a.begin(); ii!=a.end(); ii++) {
        if((*ii).second==4) cnt+=3;
        else if((*ii).second==3) cnt+=2;
        else if((*ii).second==2) cnt++;
    }
    printf("%d", cnt);
    return 0;
}

No comments:

Post a Comment