/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 311ms 592.0 KiB
#3 Accepted 314ms 592.0 KiB
#4 Accepted 412ms 584.0 KiB
#5 Accepted 31ms 580.0 KiB
#6 Accepted 30ms 544.0 KiB
#7 Accepted 29ms 552.0 KiB
#8 Accepted 27ms 556.0 KiB
#9 Time Exceeded ≥1082ms ≥596.0 KiB
#10 Time Exceeded ≥1088ms ≥584.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
// typedef
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
// define
#define MOD 			1e9+7
#define all(a)			(a).begin(),(a).end()
#define fastread()      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const double eps = 1e-9;
// debug
template<typename F,typename S>ostream&operator<<(ostream&os,const pair<F,S>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&v){os<<"{";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"}";}
template<typename T>ostream&operator<<(ostream&os,const set<T>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<",";os<<*it;}return os<<"]";}
template<typename T>ostream&operator<<(ostream&os,const multiset<T>&v) {os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"]";}
template<typename F,typename S>ostream&operator<<(ostream&os,const map<F,S>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<it->first<<" = "<<it->second;}return os<<"]";}
#define dbg(args...) do {cerr << #args << " : "; err(args); } while(0)
void err(){cerr << endl;}
template<typename T>void err(T a[],int n){for(int i=0;i<n;++i)cerr<<a[i]<<' ';cerr<<endl;}
template<typename T,typename...hello>void err(T arg,const hello&...rest){cerr<<arg<<' ';err(rest...);}
 
void init_code(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

const int N = 1e6;
 
void solve(){
	vector<int> arr(3);
	cin>>arr[0]; 
	cin>>arr[1];
	cin>>arr[2];
	sort(all(arr));
	
	if(arr[0] == arr[1] && arr[1] == arr[2]) {
		cout<<0<<endl;
		return;
	} else if(arr[0] == arr[1] || arr[1] == arr[2]){
		cout<<1<<endl;
		return;
	}

	int ans = INT_MAX;

	for(int i=1;i<N;i++){
		int x = 0;
		int d1 = (arr[1] - arr[0]);
		int d2 = (arr[2] - arr[1]);
		
		if(d1 % i ==0 && d2 % i ==0){
			int x = d1/i + d2/i;
			ans = min(ans, x);
		}
		if(d1/i == 0 || d2/i ==0) break;

	}
	cout<<ans<<endl;
}
 
int main(){
	// init_code();

	int t; cin>>t;
	while(t--)
	solve();
	
	return 0;
}








Information

Submit By
Type
Submission
Problem
P1061 Bring equality
Contest
Brain Booster #4
Language
C++20 (G++ 13.2.0)
Submit At
2024-07-14 16:14:13
Judged At
2024-11-11 03:24:28
Judged By
Score
80
Total Time
≥1088ms
Peak Memory
≥596.0 KiB