zoukankan      html  css  js  c++  java
  • URAL 1777 D

    D - Anindilyakwa
    Time Limit: 20 Sec

    Memory Limit: 256 MB

    题目连接

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87643#problem/D

    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 ≤ 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

    11 5 9

    Sample Output

    3

    HINT

    题意

    一开始有3堆石头,然后会产生差值最小的那堆石头,然后问你得多少次之后,才会产生同样个数的石头

    题解

    数据范围很小,直接暴力就好了

    代码:

    //qscqesze
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <set>
    #include <vector>
    #include <sstream>
    #include <queue>
    #include <typeinfo>
    #include <fstream>
    #include <map>
    #include <stack>
    typedef long long ll;
    using namespace std;
    //freopen("D.in","r",stdin);
    //freopen("D.out","w",stdout);
    #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
    #define maxn 125000
    #define mod 10007
    #define eps 1e-9
    int Num;
    //const int inf=0x7fffffff;   //нчоч╢С
    const int inf=0x3f3f3f3f;
    inline ll read()
    {
        ll x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
    //**************************************************************************************
    
    ll a[maxn];
    int main()
    {
        for(int i=0;i<3;i++)
            cin>>a[i];
        int tot=3;
        int ans=1;
        while(1)
        {
            sort(a,a+tot);
            ll dd=-1;
            for(int i=0;i<tot-1;i++)
            {
                if(dd==-1)
                    dd=a[i+1]-a[i];
                else
                    dd=min(dd,a[i+1]-a[i]);
            }
            if(dd==0)
            {
                cout<<ans<<endl;
                return 0;
            }
            ans++;
            a[tot++]=dd;
        }
    }
  • 相关阅读:
    重构原则
    【重构:改善既有代码的设计】读书笔记——开篇
    C#值参数和引用参数
    使用Aspose.Cells利用模板导出Excel(C#)
    在MVC中使用rdlc格式的报表
    程序员如何高效学习
    IT 圈里有哪些经常被读错的词?
    VS2017生成解决方案报错,提示对路径的访问被拒绝
    JavaScript中的数值转换
    Xadmin的配置及使用
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4728596.html
Copyright © 2011-2022 走看看