답안 #872232

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
872232 2023-11-12T14:36:52 Z NotLinux Euklid (COCI20_euklid) C++17
35 / 110
1000 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 8000;
inline int rand(int l, int r){
	  static mt19937 
	  rng(chrono::steady_clock::now().time_since_epoch().count());

	  uniform_int_distribution<int> ludo(l, r); 
	  return ludo(rng);
}
inline int gcd(int a, int b){
	if(a > b)return gcd(b,a);
	else if(a == 0)return b;
	else return gcd(b%a,a);
}
inline int R(int a, int b){
	if(a < b)return R(b,a);
	else if(a >= b and b > 1)return R(a/b,b);
	else return a;
}
void solve(){
	int g,h;
	cin >> g >> h;
	if(g == h)cout << h << " " << h << endl;
	else if(h == 2)cout << 2*g << " " << g << endl;
	else if(g == (h*h))cout << h*h << " " << h*h*h << endl;
	else{
		for(int i = 1;i<=N;i++){
			for(int j = i+1;j<=N;j++){
				if(gcd(i,j) == 1 and R(i*g,j*g) == h){
					cout << i*g << " " << j*g << endl;
					return;
				}
			}
		}
	}
}
signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int testcase = 1;cin >> testcase;
	while(testcase--)solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 348 KB Output is correct
2 Correct 24 ms 348 KB Output is correct
3 Correct 14 ms 348 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 7 ms 348 KB Output is correct
6 Correct 7 ms 348 KB Output is correct
7 Correct 6 ms 348 KB Output is correct
8 Correct 6 ms 348 KB Output is correct
9 Correct 5 ms 344 KB Output is correct
10 Correct 6 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 348 KB Output is correct
2 Correct 24 ms 348 KB Output is correct
3 Correct 14 ms 348 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 7 ms 348 KB Output is correct
6 Correct 7 ms 348 KB Output is correct
7 Correct 6 ms 348 KB Output is correct
8 Correct 6 ms 348 KB Output is correct
9 Correct 5 ms 344 KB Output is correct
10 Correct 6 ms 344 KB Output is correct
11 Correct 9 ms 348 KB Output is correct
12 Execution timed out 1077 ms 348 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 25 ms 348 KB Output is correct
24 Correct 24 ms 348 KB Output is correct
25 Correct 14 ms 348 KB Output is correct
26 Correct 10 ms 348 KB Output is correct
27 Correct 7 ms 348 KB Output is correct
28 Correct 7 ms 348 KB Output is correct
29 Correct 6 ms 348 KB Output is correct
30 Correct 6 ms 348 KB Output is correct
31 Correct 5 ms 344 KB Output is correct
32 Correct 6 ms 344 KB Output is correct
33 Correct 9 ms 348 KB Output is correct
34 Execution timed out 1077 ms 348 KB Time limit exceeded
35 Halted 0 ms 0 KB -