Search is not available for this dataset
name
stringlengths
2
88
description
stringlengths
31
8.62k
public_tests
dict
private_tests
dict
solution_type
stringclasses
2 values
programming_language
stringclasses
5 values
solution
stringlengths
1
983k
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int GCD(int a, int b) { if (b == 0) return a; else return GCD(b, a % b); } int main() { int p, q; cin >> p >> q; q /= GCD(p, q); int ans = q; map<int, int> mpa; for (int i = 2; i * i <= q; i++) { while (q % i == 0) { mpa[i]++; q /= i;...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> long long int gcd(long long int p, long long int q) { if (!q) return p; if (q > p) return gcd(q, p); return gcd(q, p % q); } int main(void) { long long int p, q; scanf("%lld%lld", &p, &q); long long int g = gcd(p, q); p /= g; q /= g; long long int b = 1; for (long long int i...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int P, Q; bool p[100000000]; vector<int> v; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } long long solve() { long long ans = 1; for (int i = ((int)0); i < ((int)v.size()); i++) if (Q % v[i] == 0) ans *= v[i]; if (ans == 1) ans *= Q; ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; import java.io.*; public class Main{ public static void main(String[] args){ solve(); } public static void solve(){ Scanner sc = new Scanner(System.in); int p = sc.nextInt(); int q = sc.nextInt(); boolean[] judge = new boolean[(int)Math.sqrt(1000000000)+5]; Arrays.fill(judge,true); ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
import math p, q = map(int, input().split()) g = math.gcd(p, q) p //= g q //= g ret = q for b in range(1, 40000): if b ** 1000 * p % q == 0: ret = min(ret, b) print(ret)
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
prime = [2] def check(x): for i in prime: if x % i ==0: return False elif x < i * i: break return True def set(): for i in range(3,10**5,2): if check(i): prime.append(i) set() #print(prime) p,q = [int(i) for i in input().split(' ')] for i in pr...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int main() { long long int p, q; cin >> p >> q; q /= gcd(p, q); double n = sqrt(q); for (long long int i = 2; i <= n; i++) { long long int x = i; while (x <= q) { if (x == q) { cout...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; import java.io.*; public class Main{ public static void main(String[] args){ solve(); } public static void solve(){ Scanner sc = new Scanner(System.in); int p = sc.nextInt(); int q = sc.nextInt(); if(q%p==0){ q /= p; p = 1; } boolean[] judge = new boolean[(int)Math.sqrt(10000...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; public class Main{ public static void main(String args[]) { Scanner scn = new Scanner(System.in); long p = scn.nextLong(), q = scn.nextLong(); scn.close(); long qs; long ans = q; long bp = p,bq = q,buf = p; while(bq % bp != 0) { buf = bq % bp; bq = bp; bp = buf; } ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; struct UnionFind { vector<int> v; UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; } int find(int x) { return v[x] == x ? x : v[x] = find(v[x]); } void unite(int x, int y) { v[find(...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<iostream> #include<algorithm> #include<cstdio> #include<cmath> #include<math.h> #include<string> #include<string.h> #include<stack> #include<queue> #include<vector> #include<utility> #include<set> #include<map> #include<stdlib.h> #include<iomanip> using namespace std; #define ll long long #define ld long do...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long p, q; long long stol(long long a, long long b) { if (a < b) swap(a, b); if (a % b == 0) return b; return stol(b, a % b); } signed main() { cin >> p >> q; cout << q / stol(p, q) << endl; }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; import java.util.ArrayList; public class Main { Scanner sc = new Scanner(System.in); public void run(){ int p = sc.nextInt(); int q = sc.nextInt(); calc(p, q); } public void calc(int p, int q){ int a = q; int b = p; int max = 0; while(true){ int c = a % b; if(c == 0){ ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int euclid(int x, int y) { int t; while (x % y) { x %= y; t = x; x = y; y = t; } return y; } int main() { int p, q; cin >> p >> q; cout << q / euclid(p, q) << endl; return 0; }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr) #define all(x) (x).begin(),(x).end() #define pb push_back #define fi first #define se second typedef pair<int,int> pi; ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int main() { int p, q; cin >> p >> q; q /= gcd(p, q); for (int i = 2; i < 32000; i++) { double x = log(q) / log(i); if (ceil(x) == floor(x)) { cout << i << endl; return 0; } } c...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long inf = 1e9; const long long mod = 1e9 + 7; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } bool check(long long q, long long i) { while (q % i == 0) { q /= i; if (q == 1) { return true; } } r...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { int p, q; scanf("%d%d", &p, &q); int x = gcd(q, p); p /= x; q /= x; for (int i = 2; i <= q; i++) { int m = q; while (!(m % i)) m /= i; if (m == 1) { printf("%d\n", i...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<bits/stdc++.h> using namespace std; int main(){ int q,p,t,ans=1,i,j,c=0; cin>>q>>p;t=p; p/=__gcd(q,p); if(p!=t&&q!=1)for(i=2;i*i<=t;i++){ if(p%i==0){ p/=i; ans*=i; i--; } } else ans=t; cout<<ans<<endl; }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b > a) { int t = b; b = a; a = t; } if (b == 0) { return a; } return gcd(b, a % b); } int main(int argc, char const *argv[]) { int a, b; cin >> a >> b; cout << b / gcd(a, b) << endl; return 0; }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int p, q, a; set<int> s; cin >> p >> q; a = q; for (int i = 2; i * i < q; i++) { s.clear(); int r = p; while (r != 0) { if (s.count(r)) break; s.insert(r); r *= i; r %= q; } if (r == 0) { a = i; ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int gcd(int p, int q) { return p % q == 0 ? q : gcd(q, p % q); } vector<int> makeprime(int num) { vector<bool> n(num + 1, true); n[0] = n[1] = false; for (int i = 2; i < num + 1; i++) { if (n[i]) { for (int j = 2; i * j <= num + 1; j++) { n[i * j] = ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<bits/stdc++.h> using namespace std; int main(){ long long p,q; cin >> p >> q; int va=q; int ans=0; for(long long i=2;i*i<=va;i++){ if(ans!=0) break; if(q%i==0){ ans=-1; while(q%i==0){ q/=i; //cout << q << endl; } if(q==1) ans=i; ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int p, q; vector<int> primes; const int MA = 10000000; bool t[MA * 2]; void eratosu() { t[1] = 1; for (int i = 2; i <= MA; i++) { if (t[i] == 0) { primes.push_back(i); for (int j = i * 2; j <= MA; j += i) t[j] = 1; } } } bool check(int x) { int a...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(x * a, y * a); ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll=long long; using vb=vector<bool>; using vvb=vector<vb>; using vd=vector<double>; using vvd=vector<vd>; using vi=vector<int>; using vvi=vector<vi>; using vl=vector<ll>; using vvl=vector<vl>; using pii=pair<int,int>; using pll=pair<ll,ll>; using tll=tuple<ll,ll>; usi...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long p, q; cin >> p >> q; int va = q; int ans = 0; for (long long i = 2; i * i <= va; i++) { if (ans != 0) break; if (q % i == 0) { ans = -1; while (q % i == 0) { q /= i; } if (q == 1) ans = i; } } ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long p, q; cin >> p >> q; long long P = p, Q = q; while (p % q != 0) { p = p % q; swap(p, q); } long long va = Q; P /= q; Q /= q; for (long long i = 2; i * i <= va; i++) { va = Q; while (Q % i == 0 && P < (Q / i)) Q /= i; ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int GCD(int a, int b) { if (b == 0) return a; else return GCD(b, a % b); } int main() { int p, q; cin >> p >> q; cout << q / GCD(p, q) << endl; return 0; }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } bool isPrime[100000]; int main() { int p, q; cin >> p >> q; int d = gcd(p, q); q /= d; fill(isPrime, isPrime + 100000, true); isPrime[0] = isPrime[1] = false; for (int i = 2; i < 100000;...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; uint32_t gcd(uint32_t p, uint32_t q) { if (q > p) return gcd(q, p); if (q == 0) return p; else return gcd(q, p % q); } int32_t main() { uint32_t p, q; cin >> p >> q; uint32_t g = gcd(p, q); cout << q / g << endl; return 0; }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using std::cin; using std::cout; using std::endl; using std::fixed; using std::list; using std::make_pair; using std::map; using std::pair; using std::priority_queue; using std::queue; using std::set; using std::setprecision; using std::stack; using std::string; using std::vector; int gcd(int p...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } int main() { int p, q, n, res = 1; cin >> p >> q; n = q / GCD(p, q); for (int i = 2; i < sqrt(n) + 2; i++) { if (n % i == 0) { res *= i; } } if (res == 1) res = 2; cout << res << endl; ret...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long p, q; cin >> p >> q; long long P = p, Q = q; while (p % q != 0) { p = p % q; swap(p, q); } long long va = Q; P /= q; Q /= q; for (long long i = 2; i * i <= va; i++) { va = Q; int count = 0; while (Q % i == 0) { ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b); signed main() { long long p; scanf("%lld", &p); ; long long q; scanf("%lld", &q); ; while (p && q) { long long base = gcd(p, q); q /= base; for (long long i = 2; i * i <= q; i++) { if (!(q % i)) { ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; uint32_t gcd(uint32_t a, uint32_t b) { if (b > a) return gcd(b, a); if (b == 0) return a; return gcd(b, a % b); } int32_t main() { uint32_t p, q; cin >> p >> q; uint32_t g = gcd(p, q); p /= g; q /= g; for (uint32_t i = 2; i <= q; i++) { uint32_t tmp = ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.ArrayList; import java.util.Scanner; public class Main{ public static void main(String args[]) { ArrayList<Long> yaku = new ArrayList<Long>(); Scanner scn = new Scanner(System.in); long p = scn.nextLong(), q = scn.nextLong(); scn.close(); long qs; long ans = q; long bp = p,bq = q,buf =...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int p, q, r = 1; int main() { scanf("%d%d", &p, &q); q = q / _gcd(p, q); for(int i = 2; i * i <= q; i++) { if(q % i == 0) { r *= i; while(q % i == 0) q /= i; } } printf("%d\n", r * q); return 0; }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long solve(long long a, long long b) { int x = max(a, b), y = min(a, b); if (x % y == 0) return y; else return solve(x % y, y); } int main() { long long p, q, r, ans; vector<long long> prime(100000); cin >> p >> q; r = solve(p, q); p /= r; q /...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<bits/stdc++.h> using namespace std; #define int long long signed main(){ int p,q; cin>>p>>q; p=q/__gcd(p,q); for(int i=2;i*i<=p;i++){ if(p%i)continue; int t=p; while(t%i==0)t/=i; if(t==1){ cout<<i<<endl; return 0; } } cout<<p<<endl; return 0; }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<iostream> #include<algorithm> #include<cstdio> #include<cmath> #include<math.h> #include<string> #include<string.h> #include<stack> #include<queue> #include<vector> #include<utility> #include<set> #include<map> #include<stdlib.h> #include<iomanip> using namespace std; #define ll long long #define ld long dou...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using std::cin; using std::cout; using std::endl; using std::fixed; using std::list; using std::make_pair; using std::map; using std::pair; using std::priority_queue; using std::queue; using std::set; using std::setprecision; using std::stack; using std::string; using std::vector; int gcd(int p...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using ll = long long; using namespace std; int const MOD = 1e9 + 7; int GCD(int x, int y) { if (y == 0) return x; return GCD(y, x % y); } int main(void) { ll p, q; cin >> p >> q; int d = GCD(p, q); p /= d; q /= d; map<ll, ll> mp; for (ll i = 2; i < 10000; ++i) { for (ll j ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (b == 0) return a; else return gcd(b, a % b); } vector<bool> prime(1000000000 + 1, true); void make(long long int M) { prime[0] = prime[1] = false; for (long long int i = 2; i * i < M + 1; i++) { i...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<bits/stdc++.h> using namespace std; int main(){ int q,p,t,ans=1,i,j,c; cin>>q>>p;t=p; p/=__gcd(q,p); for(i=2;i*i<=t*2;i++){ if(p%i==0){ p/=i; ans*=i; i--; } } cout<<ans<<endl; }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main(void) { int p, q; scanf("%d %d", &p, &q); printf("%d\n", gcd(p, q)); return 0; }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long p, q; cin >> p >> q; int va = q; int ans = 0; for (long long i = 2; i * i <= va; i++) { if (ans != 0) break; if (q % i == 0) { ans = -1; while (q % i == 0) { q /= i; } if (q == 1) ans = i; } } ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<bits/stdc++.h> using namespace std; int main(){ int q,p,t,ans=1,i,j,c=0; cin>>q>>p;t=p; p/=__gcd(q,p); if(p!=t||q==1)for(i=2;i*i<=t;i++){ if(p%i==0){ p/=i; if(ans%i)ans*=i; i--; } } else ans=t; cout<<ans<<endl; }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a < b) swap(a, b); if (b == 0) return a; return gcd(b, a % b); } signed main() { long long p, q; cin >> p >> q; cout << max((long long)2, q / gcd(p, q)) << endl; }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int in(void) { int i; scanf("%d", &i); return i; } long long llin(void) { long long i; scanf("%lld", &i); return i; } void print(int a) { printf("%d\n", a); } void llprint(long long a) { printf("%lld\n", a); } void print2(int a, int b) { printf("%d %d\n", a, b); } long long max(long...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int lcm(int a, int b) { if (a < b) { swap(a, b); } if (!b) { return a; } return lcm(b, a % b); } int main() { int i, p, q, lc, cl; double lm, buf, df, m; cin >> p >> q; lc = lcm(p, q); p /= lc; q /= lc; lm = log(q) / log(2); cl = (int)lm + ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int p, q; vector<int> primes; bool check(int a) { int aa = a; while (a <= q) { if (q % a == 0) return 1; a *= aa; } return 0; } bool t[10000000]; void eratosu() { t[1] = 1; for (int i = 2; i <= 10000000; i++) { if (t[i] == 0) { primes.push_back...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a < b) swap(a, b); if (b == 0) return a; return gcd(b, a % b); } int main() { long long a, b; cin >> a >> b; long long c = gcd(a, b); a /= c; b /= c; for (int i = 2; i < 111111; i++) { if (b % i == 0) { ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import math f=lambda n:min(int(i) for i in (round(n**(1/i),10) for i in range(1,int(math.log(n,2))+2)) if int(i)==i) p,q=map(int,input().split()) if f(q)==q: e=math.gcd(p,q) q/=e e=f(q) if f(q)!=q: q=e print(int(q))
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; import java.util.ArrayList; public class Main { Scanner sc = new Scanner(System.in); public void run(){ int p = sc.nextInt(); int q = sc.nextInt(); calc(p, q); } public void calc(int p, int q){ int a = q; int b = p; int max = 0; while(true){ int c = a % b; if(c == 0){ ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100005; map<int, int> mp; int gcd(int a, int b) { if (a % b == 0) { return b; } return gcd(b, a % b); } int main() { int p, q; cin >> p >> q; q /= gcd(p, q); int i = 2; while (i * i <= 1000000000) { mp[i * i] = i; i++; } whi...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; while (1) { int stat = 0; for (int i = 2; i <= sqrt(max(a, b)); i++) { if (a % i == 0 && b % i == 0) { stat = 1; a /= i; b /= i; break; } } if (stat == 0) break; } co...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int p, q; cin >> p >> q; for (int i = 2; i < 1e9; i += 2) { if (q % i == 0 && p % (q / i) == 0) { cout << i << endl; break; } if (i == 2) i--; } return 0; }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int p, q, use; int so[40000] = {0}; cin >> p >> q; use = q; int a; while (q % p != 0) { a = q % p; q = p; p = a; } use /= p; q = use; vector<int> sonaka; for (int i = 2; i < 20000; i++) if (so[i] == 0) { sonaka.push_b...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
from math import gcd p,q=[int(i) for i in input().split()] g = gcd(p,q) q//=g prime=[] p=2 while p<q: if q%p==0: prime.append(p) q//=p else: p+=1 if q!=1: prime.append(q) prime=set(prime) if len(prime)==0: print(q) else: res=1 for p in prime: res*=p print(re...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int in(void) { int i; scanf("%d", &i); return i; } long long llin(void) { long long i; scanf("%lld", &i); return i; } void print(int a) { printf("%d\n", a); } void llprint(long long a) { printf("%lld\n", a); } void print2(int a, int b) { printf("%d %d\n", a, b); } long long max(long...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> const double EPS = (1e-10); using namespace std; using Int = long long; const Int MOD = 1000000007; void fast_input() { cin.tie(0); ios::sync_with_stdio(false); } vector<int> primeFactorization(int n) { int k = n; vector<int> ret; for (int i = 2; i <= sqrt(n); i++) { while (k % i ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using std::cerr; using std::cin; using std::cout; using std::endl; int gcd(int p, int q) { if (q > p) std::swap(p, q); while (p % q != 0) { int r = p % q; p = q; q = r; } return q; } int main(void) { cout << std::fixed << std::setprecision(10); cin.tie(0); std::ios::sy...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int GCD(int a, int b) { if (b == 0) return a; else return GCD(b, a % b); } int main() { int p, q; cin >> p >> q; q /= GCD(p, q); int ans = q; set<int> sta; for (int i = 2; i * i <= q; i++) { if (q % i == 0) sta.insert(i); } set<int>::iterator...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (int)(n); ++i) using ll = long long; int main(){ ll p,q; while(cin >> p >> q){ ll ans = 1; for(int i = 2; i <= 1e5; ++i){ int c = 0; while(p%i == 0) p/=i, ++c; while(q%i == 0) q...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using std::cin; using std::cout; using std::endl; int gcd(int n, int m) { if (n % m == 0) { return m; } else { return gcd(m, n % m); } } int main(void) { int p, q; cin >> p >> q; int n = q; int m = p; int l = gcd(n, m); while (l != 1) { n = n / l; m = m / l; ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int p, q, a; set<int> s; cin >> p >> q; a = q; for (int i = 2; i < q / 2; i++) { s.clear(); int r = p; while (r != 0) { if (s.count(r)) break; s.insert(r); r *= i; r %= q; } if (r == 0) { a = i; ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long int LCM(long long int a, long long int b) { long long int dummy1, dummy2, dummy; dummy1 = max(a, b); dummy2 = min(a, b); while (true) { dummy = dummy1 % dummy2; dummy1 = dummy2; dummy2 = dummy; if (dummy == 0) { break; } } ret...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int p, q, x, test; cin >> p >> q; if (p < q) swap(p, q); test = p; while (1) { if (p % q != 0) { x = p % q; p = q; q = x; continue; } break; } int tmp = test / q; int ans = tmp; for (int i = 2; i <= sqrt(tmp...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using ll = long long; using namespace std; int const MOD = 1e9 + 7; int GCD(int x, int y) { if (y == 0) return x; return GCD(y, x % y); } int main(void) { ll p, q; cin >> p >> q; int d = GCD(p, q); p /= d; q /= d; bool prime_check = true; for (ll i = 2; i * i <= q; ++i) { ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<bits/stdc++.h> using namespace std; int main(){ int p,q; cin>>p>>q; p=q/__gcd(p,q); int f=0; for(int i=2;i*1<p;i++){ if(p%i)continue; f=i; break; } if(f==0){ cout<<p<<endl; return 0; } int t=p; while(t%f==0&&t!=1)t/=f; if(t==1)cout<<f<<endl; else cout<<p<<endl; return 0; }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using vs = vector<string>; using msi = map<string, int>; using mii = map<int, int>; using pii = pair<int, int>; using vlai = valarray<int>; using ll = long long; constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { int p, q; scanf("%d%d", &p, &q); int x = gcd(q, p); p /= x; q /= x; bool ok = true; for (int i = 2; i <= sqrt(q); i++) { int m = q; while (!(m % i)) m /= i; if (m == 1) ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int p, q, ans = 1, j; int so(int n) { for (int i = 2; i * i <= n; i++) if (n % i == 0) return 1; return 0; } int main() { cin >> p >> q; if (so(q)) { for (int i = 2; q >= i; i++) { for (j = 0; q % i == 0; j++) q /= i; if (j == 0) continue; ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int p, q; vector<int> yakusuu; int main() { cin >> p >> q; for (int i = 2; i <= p / 2; i++) { if (p % i == 0) { yakusuu.push_back(i); } } for (int j = 0; j < yakusuu.size(); j++) { if (q % yakusuu[j] == 0) q = q / yakusuu[j]; } cout << q << end...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(){ int p,q; cin>>p>>q; int a=__gcd(p,q); p/=a,q/=a; for(int i=2;i*i<=q;i++){ if(q%i!=0)continue; while((q/i)%i==0)q/=i; while((q/(q/i))%(q/i)==0)q/=(q/i); } cout <<q<<endl; return 0; }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int p, q, use; int so[40000] = {0}; cin >> p >> q; use = q; int a; while (q % p) { a = q % p; q = p; p = a; } use /= p; vector<int> sonaka; for (int i = 2; i < 40000; i++) if (!so[i]) { sonaka.push_back(i); for (i...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; uint32_t gcd(uint32_t p, uint32_t q) { if (q > p) return gcd(q, p); if (q == 0) return p; else return gcd(q, p % q); } int32_t main() { uint32_t p, q; cin >> p >> q; uint32_t g = gcd(p, q); uint32_t qq = q / g; if (p / g != 1) { cout << qq << end...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> const int INF = 100000000; using namespace std; int gcd(int x, int y) { int r; if (x < y) swap(x, y); while (y > 0) { r = x % y; x = y; y = r; } return x; } int main() { int p, q; cin >> p >> q; int x = gcd(p, q); q /= x; bool f = false; for (int i = 2; i * i <...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int p, q; cin >> p >> q; int r = gcd(q, p); p /= r; q /= r; int ans = 1; for (int i = 2; i * i <= q; i++) { if (q % i != 0) continue; ans *= i; while (q % i == 0...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long p, q; cin >> p >> q; long long P = p, Q = q; while (p % q != 0) { p = p % q; swap(p, q); } long long va = Q; P /= q; Q /= q; for (long long i = 2; i * i <= va; i++) { va = Q; int count = 0; while (Q % i == 0 && Q ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long inf = 1e9; const long long mod = 1e9 + 7; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } bool check(long long q, long long i) { while (q % i == 0) { q /= i; if (q == 1) { return true; } } r...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.util.NoSuchElementException; public class Main { static PrintWriter out; static InputReader ir; static void solve() { int p = ir.nextInt(); int q = ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int gcd(int a, int b) { if (b == 0) return a; if (a > b) return gcd(b, a % b); return gcd(a, b % a); } int main(void) { int p, q, g, f2, f5, t; scanf("%d %d", &p, &q); g = gcd(p, q); q /= g; f2 = f5 = 0; t = q; while (t % 2 == 0) { f2 = 1; t /= 2; } if (t == 1) {...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int pr[50847534]; int x = 0; int nextpr(int p) { int nxp = p + 2; int i; int ok = 1; pr[x] = p; x++; if (p == 2) return 3; while (1) { for (i = 0; pr[i] * pr[i] <= nxp; i++) { ok = 1; if (nxp % pr[i] == 0) { ok = 0; break; } } if (ok) ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int P, Q; int solve() { int b = 2; while (1) { int n = P; for (int j = ((int)0); j < ((int)b); j++) { int s = n * b / Q; n = n * b - Q * s; } if (n == 0) break; b++; } return b; } int main(void) { cin >> P >> Q; cout << solve() <<...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int main() { long long int p, q; cin >> p >> q; q /= gcd(p, q); for (long long int i = 2;; i++) { long long int x = i; while (x <= q) { if (x == q) { cout << i << endl; return...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int euclid(int x, int y) { int t; while (x % y) { x %= y; t = x; x = y; y = t; } return y; } int main() { int p, q, n, m, t = 2, ans = 1; cin >> p >> q; n = q / euclid(p, q); m = n; map<int, int> f; while (n > 1 && t < sqrt(m) + 1) { ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int COU(int a, int b) { if (a == b || a == 0) return 1; while (true) { if (a == b) return a; if (a < b) { int t = a; a = b, b = t; } a -= b; } } int main() { int p, q; cin >> p >> q; cout << q / COU(p, q) << endl; return 0; }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long p, q; cin >> p >> q; for (long long i = 2; i * i <= q; i++) { if (p % i == 0 && q % i == 0) { do { p /= i; q /= i; } while (p % i == 0 && q % i == 0); } } cout << p << " " << q << endl; for (int i = 2; i...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long p, q; long long int gcd(long long int x, long long int y) { if (x % y == 0) return y; return gcd(y, x % y); } int main() { cin >> p >> q; long long g = gcd(p, q); p /= g; q /= g; cout << q << "\n"; }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long gcd(long a, long b) { if (b == 0) return a; return gcd(b, a % b); } int main() { long p, q; cin >> p >> q; long tmp = gcd(q, p); p /= tmp; q /= tmp; long ans = 1; long root = sqrt(q) + 1; vector<bool> hurui(q + 1, true); for (int i = 2; i <= q / 2...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; import java.util.ArrayList; public class Main { Scanner sc = new Scanner(System.in); public void run(){ int p = sc.nextInt(); int q = sc.nextInt(); calc((long)p, (long)q); } public void calc(long p, long q){ long a = q; long b = p; long max = 0; while(true){ long c = a % ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int p, q; vector<int> primes; const int MA = 10000000; bool t[MA]; void eratosu() { t[1] = 1; for (int i = 2; i <= MA; i++) { if (t[i] == 0) { primes.push_back(i); for (int j = i * 2; j <= MA; j += i) t[j] = 1; } } } int main() { eratosu(); cin...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; import java.util.ArrayList; public class Main { Scanner sc = new Scanner(System.in); public void run(){ int p = sc.nextInt(); int q = sc.nextInt(); calc(p, q); } public void calc(int p, int q){ int a = q; int b = p; int ans = 0; while(true){ int c = a % b; if(c == 0){ ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } vector<bool> primes; void make_primes(int n) { primes.resize(n + 1, true); primes[0] = primes[1] = false; for (int i = 2; i < sqrt(n); i++) { if (primes[i]) { ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int p, q, use; int so[40000] = {0}; cin >> p >> q; use = q; int a; while (q % p != 0) { a = q % p; q = p; p = a; } use /= p; q = use; vector<int> sonaka; for (int i = 2; i < 20000; i++) if (so[i] == 0) { sonaka.push_b...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { int p, q; cin >> p >> q; q = q / gcd(p, q); vector<int> v; for (int i = 2; i <= q; i++) { if (q % i == 0) { v.push_back(i); while (q % i == 0) q /= ...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int p, q; vector<int> primes; const int MA = 10000000; bool t[MA * 2]; void eratosu() { t[1] = 1; for (int i = 2; i <= MA; i++) { if (t[i] == 0) { primes.push_back(i); for (int j = i * 2; j <= MA; j += i) t[j] = 1; } } } bool check(int x) { int a...
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int yaku(int n, int m) { if (n % m == 0) { return m; } return yaku(m, n % m); } int main() { int n, m; cin >> n >> m; m /= yaku(n, m); int ans = 1; for (int i = 2; i <= m; i++) { if (m % i == 0) { ans *= i; while (m % i == 0) { m ...