Anindilyakwa(简单)

Anindilyakwa
Time Limit:500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

The language of Australian aborigines anindilyakwa has no numerals. No anindilyakwa can say: “I've hooked eight fishes”. Instead, he says: “I've hooked as many fishes as many stones are in this pile”.
Professor Brian Butterworth found a meadow with three piles of stones. He decided to determine whether aborigines can count. Professor asked one of the aborigines to point at two piles with the minimal difference of numbers of stones in them and tell what this difference is. The aborigine pointed correctly! He was unable to express the difference with words, so he went to a shore and returned with a pile of the corresponding number of stones.
Professor decided to continue his experiments with other aborigines, until one of them points at two piles with equal number of stones. All piles that aborigines bring from the shore are left at the meadow. So, the second aborigine will have to deal with one more pile, the one brought by the first aborigine.

Input

The only input line contains space-separated pairwise distinct integers  x 1x 2 and  x 3  (1 ≤  x 1x 2x 3 ≤ 10 18) , which are the numbers of stones in piles that were lying on the meadow at the moment professor Butterworth asked the first aborigine.

Output

Output the number of aborigines that will have to answer a stupid question by professor.

Sample Input

input output
11 5 9
3

Hint

The first aborigine will point at piles of 11 and 9 stones and will bring a pile of two stones. The second aborigine will point at the same piles and will bring another pile of two stones. The third aborigine will point at two piles of two stones, and the experiments will be over.

AC CODE:

//Memory: 288 KB		Time: 31 MS
//Language: C++		Result: Accepted

#include <iostream>
using namespace std;

long long Min(long long a, long long b)
{
    return a > b ? b : a;
}

long long Abs(long long a)
{
    return a >= 0 ? a : -a;
}

int main()
{
    long long x[10000], min;
    int k;
    while(cin >> x[0] >> x[1] >> x[2])
    {
        min = Min(Abs(x[0] - x[1]), Abs(x[0] - x[2]));
        min = Min(min, Abs(x[1] - x[2]));
        k = 3;
        x[k] = min;
        while(min)
        {
            for(int i = 0; i < k; i++)
                min = Min(Abs(x[k] - x[i]), min);
            if(min)
                x[++k] = min;
        }
        cout << k - 1 << endl;
    }
    return 0;
}


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值