Submission #448193

# Submission time Handle Problem Language Result Execution time Memory
448193 2021-07-29T08:42:49 Z Apiram Euklid (COCI20_euklid) C++14
0 / 110
1000 ms 440 KB
#include<bits/stdc++.h>
using namespace std;
int64_t solve(int a,int b){
	if (a==1){
		return b;
	}
	if (b==1)return a;
	if (a<b)solve(b/a,a);
	else
	return solve(a/b, b);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int test;cin>>test;
while(test--){
	int64_t g,h;
	cin>>g>>h;
	if (g==1){
		cout<<1<<" "<<h<<endl;
		continue;
	}
	vector<pair<int,int>>ans;
	for (int i = g;i<=20000;i+=g){
		for (int j =g;j<=i;j+=g){
			if (__gcd(i,j)==g){
				if (solve(i,j)==h){
					ans.push_back({i,j});
					break;
				}			
			}
		}
		if (!ans.empty())break;
	}
	cout<<ans[0].first<<" "<<ans[0].second<<endl;
}
return 0;}

Compilation message

euklid.cpp: In function 'int64_t solve(int, int)':
euklid.cpp:8:15: warning: control reaches end of non-void function [-Wreturn-type]
    8 |  if (a<b)solve(b/a,a);
      |          ~~~~~^~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 440 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 440 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -