Submission #332248

# Submission time Handle Problem Language Result Execution time Memory
332248 2020-12-01T19:01:12 Z DanerZein Euklid (COCI20_euklid) C++14
35 / 110
1000 ms 508 KB
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(b==0) return a;
  return gcd(b,a%b);
}
int R(int a,int b){
  if(b>a) swap(a,b);
  if(b==1) return a;
  if(a==1) return b;
  return R(a/b,b);
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin>>t;
  while(t--){
    int g,h;
    cin>>g>>h;
    if(g==h){
      cout<<g<<" "<<h<<endl;
      continue;
    }
    if(h==2){
      cout<<g<<" "<<2*g<<endl;
      continue;
    }
    if(h*h==g){
      cout<<g<<" "<<h*g<<endl;
      continue;
    }
    bool sw=0;
    for(int i=1;i<=10000;i++){
      for(int j=1;j<=10000;j++){
	if(R(i,j)==h && g==gcd(i,j)){
	  cout<<i<<" "<<j<<endl;
	  sw=1;
	  break;
	}
      }
      if(sw) break;
    }
  }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 508 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 364 KB Output is correct
2 Correct 133 ms 364 KB Output is correct
3 Correct 143 ms 364 KB Output is correct
4 Correct 164 ms 364 KB Output is correct
5 Correct 162 ms 364 KB Output is correct
6 Correct 195 ms 364 KB Output is correct
7 Correct 222 ms 364 KB Output is correct
8 Correct 252 ms 364 KB Output is correct
9 Correct 281 ms 364 KB Output is correct
10 Correct 319 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 364 KB Output is correct
2 Correct 133 ms 364 KB Output is correct
3 Correct 143 ms 364 KB Output is correct
4 Correct 164 ms 364 KB Output is correct
5 Correct 162 ms 364 KB Output is correct
6 Correct 195 ms 364 KB Output is correct
7 Correct 222 ms 364 KB Output is correct
8 Correct 252 ms 364 KB Output is correct
9 Correct 281 ms 364 KB Output is correct
10 Correct 319 ms 364 KB Output is correct
11 Execution timed out 1060 ms 388 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 508 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 67 ms 364 KB Output is correct
24 Correct 133 ms 364 KB Output is correct
25 Correct 143 ms 364 KB Output is correct
26 Correct 164 ms 364 KB Output is correct
27 Correct 162 ms 364 KB Output is correct
28 Correct 195 ms 364 KB Output is correct
29 Correct 222 ms 364 KB Output is correct
30 Correct 252 ms 364 KB Output is correct
31 Correct 281 ms 364 KB Output is correct
32 Correct 319 ms 364 KB Output is correct
33 Execution timed out 1060 ms 388 KB Time limit exceeded
34 Halted 0 ms 0 KB -