D - Anindilyakwa
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87643#problem/D
Description
Input
The only input line contains space-separated pairwise distinct integers x1, x2 and x3 (1 ≤ x1, x2, x3 ≤ 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; } }