zoukankan      html  css  js  c++  java
  • 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 x1x2 and x3 (1 ≤ x1x2x3 ≤ 1018), 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

    inputoutput
    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:

     1 //Memory: 288 KB        Time: 31 MS
     2 //Language: C++        Result: Accepted
     3 
     4 #include <iostream>
     5 using namespace std;
     6 
     7 long long Min(long long a, long long b)
     8 {
     9     return a > b ? b : a;
    10 }
    11 
    12 long long Abs(long long a)
    13 {
    14     return a >= 0 ? a : -a;
    15 }
    16 
    17 int main()
    18 {
    19     long long x[10000], min;
    20     int k;
    21     while(cin >> x[0] >> x[1] >> x[2])
    22     {
    23         min = Min(Abs(x[0] - x[1]), Abs(x[0] - x[2]));
    24         min = Min(min, Abs(x[1] - x[2]));
    25         k = 3;
    26         x[k] = min;
    27         while(min)
    28         {
    29             for(int i = 0; i < k; i++)
    30                 min = Min(Abs(x[k] - x[i]), min);
    31             if(min)
    32                 x[++k] = min;
    33         }
    34         cout << k - 1 << endl;
    35     }
    36     return 0;
    37 }
  • 相关阅读:
    Python字典dict对象方法总结
    PythonString字符串的相关方法
    Mysql5.7.20使用group by查询(select *)时出现错误修改sql mode
    HtmlTestRunner无法生成HTML报告问题
    话说 type 之 record 记录的使用技巧 F#
    Silverlight OOB 获取桌面可视尺寸 F# PInvoke
    目前让 F# 支持 Silverlight 5 的解决方案(包括 lazy 不可用)
    话说 type 之 let 绑定与 val 显式字段 F#
    这两天自己模仿写的一个Asp.Net的显示分页方法 附加实体转换和存储过程 带源码下载
    Asp.net 在三层架构中事务的使用
  • 原文地址:https://www.cnblogs.com/cszlg/p/2910481.html
Copyright © 2011-2022 走看看