zoukankan      html  css  js  c++  java
  • B

    Problem description

    Valera the Horse is going to the party with friends. He has been following the fashion trends for a while, and he knows that it is very popular to wear all horseshoes of different color. Valera has got four horseshoes left from the last year, but maybe some of them have the same color. In this case he needs to go to the store and buy some few more horseshoes, not to lose face in front of his stylish comrades.

    Fortunately, the store sells horseshoes of all colors under the sun and Valera has enough money to buy any four of them. However, in order to save the money, he would like to spend as little money as possible, so you need to help Valera and determine what is the minimum number of horseshoes he needs to buy to wear four horseshoes of different colors to a party.

    Input

    The first line contains four space-separated integers s1, s2, s3, s4 (1 ≤ s1, s2, s3, s4 ≤ 109) — the colors of horseshoes Valera has.

    Consider all possible colors indexed with integers.

    Output

    Print a single integer — the minimum number of horseshoes Valera needs to buy.

    Examples

    Input

    1 7 3 3

    Output

    1

    Input

    7 7 7 7

    Output

    3
    解题思路:题目的意思就是将相同的数替换掉多少个数后才能使4个数都不相同,求替换掉的个数,set容器水过!
    AC代码:
    1 #include<bits/stdc++.h>
    2 using namespace std;
    3 int main(){
    4     int s;set<int> se;
    5     for(int i=1;i<=4;++i){cin>>s;se.insert(s);}
    6     cout<<4-se.size()<<endl;
    7     return 0;
    8 }
  • 相关阅读:
    Java:Excel文件上传至后台
    JDK1.8中的HashMap实现
    Redis远程连接报错解决
    Redis操作命令总结
    HashMap实现原理及源码分析
    谈谈对Spring IOC的理解
    centos 7.3 服务器环境搭建——MySQL 安装和配置
    Linux系统下 docker安装命令
    JS求两个数组的交集 (假设数组已经经过排序)
    作用域和作用域链
  • 原文地址:https://www.cnblogs.com/acgoto/p/9179024.html
Copyright © 2011-2022 走看看