prompt string | response string |
|---|---|
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.*;
import java.lang.Math;
import java.util.*;
public class Main
{
public BufferedReader in;
public PrintStream out;
public boolean log_enabled = true;
static int[] primes;
static int p_count;
public static void get_primes(int n)
{
primes = new int[1000000];
boolean[] v = new boolean[... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const char al[100] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
int main() {
long long int n, m;
cin >> n >> m;
vector<long long int> n... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author George Marcus
*/
public class Main {
public st... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int N = (int)1e7 + 7;
const int Mx = (int)1e7;
int n, m;
int A[N], B[N];
int lp[N];
map<int, vector<int> > a, b;
void precalc() {
for (int i = 2; i <= Mx; i++) {
if (!lp[i]) {
lp[i] = i;
if (i * 1ll * i <= Mx) {
for (int j = i * i; j <= Mx; j... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.DataInputStream;
import java.io.InputStream;
import java.io.PrintWriter;
public class C {
static class Parser {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Parser(In... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.HashMap;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import ja... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
void read_file(bool outToFile = true) {}
int n, m;
int A[100000 + 9], B[100000 + 9];
int cntA[10000000 + 1 + 9], cntB[10000000 + 1 + 9];
bitset<10000000 + 1 + 9> isPrime;
vector<int> prime;
int pdiv[10000000 + 1 + 9];
void sieve() {
isPrime.set();
isPrime[0] = isPrime[1... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.*;
import java.util.*;
public class cf222c {
public static void main(String[] args) {
FastIO in = new FastIO(), out = in;
int MAX = 10000010;
int[] next = new int[MAX];
boolean[] isPrime = new boolean[MAX];
Arrays.fill(isPrime, true);
isPrime[0] = isPrime[1] = false;
next[0... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int p[10000001];
int fa[10000001], fb[10000001];
int a[100005], b[100005];
void gao(int n, int x[], int g[]) {
for (int i = 0; i < n; ++i) {
scanf("%d", &x[i]);
for (int y = x[i]; y > 1; y /= p[y]) ++g[p[y]];
}
}
void output(int x[], int n, int f[]) {
for (int... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int nom[100005], dem[100005], primes[1000006] = {2}, cnt = 1, n, m;
map<int, int> cnom, cdem, com, factsup[100005], factsdn[100005];
int p[10000007];
void sieve() {
for (int i = 1; i <= 10000000; i++) {
p[i] = i;
}
for (int i = 2; i <= 3163; i++) {
if (p[i] ==... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
bool p[10000001] = {0};
int prime[10000001], np = 0;
int pa[10000001] = {0}, pb[10000001] = {0};
int ina[100001], inb[100001], a[100001], b[100001];
vector<int> s1, s2;
int main() {
for (int i = 2; i <= 10000000; i++)
if (!p[i]) {
prime[np++] = i;
for (int... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 1e7 + 5;
const long long INF = 9e18;
const int M = 1e5 + 5;
map<long long, vector<int> > f;
long long p[N], ans1[M], a[M];
void solve() {
for (int i = 2; i <= N; ++i) {
if (i % 2 == 0) {
p[i] = 2;
continue;
}
... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 5;
const int M = 10000000;
int big[N];
void sieve() {
big[1] = 1;
for (int i = 2; i < N; ++i) {
if (!big[i]) {
big[i] = i;
for (long long j = 1ll * i * i; j < N; j += i) {
big[j] = i;
}
}
}
}
int n, m, a[100005], b... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.*;
import java.math.*;
import java.util.*;
public class Main
{
static long mod=((long)1e9)+7;//toString
public static int gcd(int a,int b){if(b==0)return a;else return gcd(b,a%b);}
public static long pow_mod(long x,long y){long res=1;x=x%mod;while(y > 0){if((y & 1)==1)res=(res * x)%mod;y=y>>1... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int N = int(1e7) + 100;
int sp[N];
int main() {
sp[1] = 1;
for (int i = 2; i < N; i++) {
if (sp[i]) continue;
sp[i] = i;
for (long long j = (long long)i * i; j < N; j += i) {
sp[j] = i;
}
}
int n, m;
cin >> n >> m;
vector<int> a(n), a... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
long long pow(long long a, long long b, long long m) {
if (a == 0) return 0;
if (b == 0) return 1;
long long temp = pow(a, b / 2, m);
temp = ((temp % m) * (temp % m)) % m;
if (b & 1) temp = ((temp % m) * (a % m)) % m;
return temp;
}
long long string_to_num(strin... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
const int MaxN = 100010, MaxAB = 10000010;
int N, M, a[MaxN], b[MaxN], A[MaxAB], B[MaxAB], prm[MaxAB];
void work(int N, int* a, int* A) {
for (int i = 1; i <= N; ++i) {
scanf("%d", &a[i]);
for (int j = a[i]; j > 1; j /= prm[j]) ++A[prm[j]];
}
}
void prt(int N, int* a, int* B) {
fo... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N = 1e7 + 7;
int prime[N];
int l[N], r[N];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
for (int i = 2; i < N; i++) {
if (!prime[i]) {
prime[i] = i;
for (int j... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> gao[10000000];
int a[100000], b[100000];
vector<int> p;
bool visit[10000];
void prework() {
for (int i = 2; i < 10000; i++) {
if (!visit[i]) {
p.push_back(i);
for (int j = i + i; j < 10000; j += i) visit[j] = true;
}
}
}
int mai... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5, M = 1e7 + 7;
vector<long long int> spf(M);
map<long long, long long> tot;
vector<long long int> a(N, 1), b(N, 1);
vector<vector<long long> > ans(2, vector<long long int>());
void seive() {
spf[0] = spf[1] = 1;
for (long long int i = 0; i < M... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class C
{
static class Scanner
{
BufferedReader br;
StringTokenizer st;
... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
return x > 0 ? x : -x;
}
const int MAX = 10000000;
int n;
int m;
int p[700000];
vector<pair<int, int> > v[2][700000];
int f[MAX + 1];
int r = 0;
int x[100000];
int y[100000];
int add(int x, int q, int i) {
for (int j = 0; p[j] * p[j] <= x... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... |
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Map.Entry;
public class C {
public static void main(String[] args) {
InputReader in ... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int l, a[100005], b[100005], fz[100005 * 10], fw[100005 * 10], mp[100005 * 100];
bool vis[10000005];
vector<int> vec;
void gao1(int x, int f[]) {
int len = vec.size();
for (int i = 0; i < len; i++) {
int y = vec[i];
if (x % y == 0) {
if (mp[y] == -1) mp[y]... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... |
import java.io.*;
import java.lang.reflect.Array;
import java.math.*;
import java.security.*;
import java.util.*;
public class Main {
private static int [] [] cnt;
private static int [] prime;
private static int MAX = 10*1000*1000;
private static int [] [] to_lose;
private static void sieve(){
... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int N, M;
int A[100002];
int B[100002];
int pr[10000002];
int divA[10000002];
int divB[10000002];
void Solution(int n, int *X, int *Y) {
for (int i = 1; i <= n; i++) {
int ans = 1;
for (int j = X[i]; j > 1; j /= pr[j]) {
if (Y[pr[j]])
Y[pr[j]]--;
... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int i, j, m, n, p, k, k1, l = 0, r;
struct Node {
int ed, before;
} s[3000001];
int Prime[2][10000001], A[1000001], B[1000001], vis[10000001], fox[10000001],
Vis[100001], prime[100001];
void add(int x, int y) {
s[++k1].ed = y;
s[k1].before = fox[x];
fox[x] = k1;... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
string toString(T x) {
if (x == 0) return "0";
bool negative = x < 0;
string res;
while (x) {
res.push_back('0' + x % 10);
x /= 10;
}
if (negative) res.push_back('-');
reverse(res.begin(), res.end());
return res;
}
void ioFromFi... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 100007, maxt = 10000007;
int n, m;
int a[maxn], b[maxn];
int A[maxt], B[maxt], C[maxt], D[maxt];
int fac[maxt];
void gao(int x, int A[]) {
for (int i = x; i > 1; i /= fac[i]) A[fac[i]]++;
}
void Do(int &x, int A[]) {
for (int i = x; i > 1; i /= fac[i])
... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 1, inf = 1e9, mod = 1e9 + 7, M = 1e5 + 1;
const long long linf = 1e18;
int maxn = 1e7, p[N], n, m, x, ans[2][M], num[N];
vector<int> g[2][(int)(8e5)], prime;
int main() {
time_t st = clock();
prime.push_back(2);
for (int i = 2; i <= maxn; i += 2) p... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
map<long long, vector<int>> num, dem;
long long n, m, x, a[N], b[N];
bool prime[10000007];
vector<long long> v, v2;
void sieve() {
memset(prime, 1, sizeof prime);
prime[0] = prime[1] = 0;
for (int i = 2; i * i <= 1e7; i++) {
if (prime[i])
... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int inf_int = 2e9;
long long inf_ll = 2e18;
const double pi = 3.1415926535898;
template <typename T>
void prin(vector<T>& a) {
for (int i = 0; i < a.size(); i++) {
cout << a[i];
if (i < a.size() - 1)
cout << " ";
else
cout << "\n";
}
}
template <... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:268435456")
#pragma warning(disable : 4996)
using namespace std;
const int V = 1e7 + 100, N = 1e5 + 100, S = 3200;
int pr[S], a[N], b[N];
vector<int> d[V];
bool comp[S];
int p = 0;
int main() {
for (int i = 2; i < S; i++) {
if (!comp[i]) {
pr[p++] = i... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.BitSet;
import java.io.InputStream;
/**
* Built using CHelper... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e7 + 7;
const int maxnn = 1e5 + 7;
int prime[maxn];
int row[maxnn], col[maxnn];
int up[maxn], down[maxn];
void init() {
for (int i = 2; i <= 10000000; i++) {
if (!prime[i]) {
prime[i] = i;
for (int j = i + i; j <= 10000000; j += i) {
... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
inline int sqr(int x) { return x * x; }
inline int cube(int x) { return x * x * x; }
inline long long sqrLL(long long x) { return x * x; }
inline long long cubeLL(long long x) { return x * x * x; }
const long long LLINF = 9223372036854775807LL;
const long long LLINF17 = 100... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int dx[]{1, -1, 0, 0, 1, -1, 1, -1};
int dy[]{0, 0, 1, -1, 1, -1, -1, 1};
const int size = 10000007;
int ar[size], A[size], B[size], inA[size], inB[size];
void cal() {
for (long long i = 2; i < size; i++) {
if (ar[i] == 0) {
for (int j = i; j < size; j += i) ar[... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 5;
int n, m;
int sieve[N], prime[N];
int a[2][N], f[2][N];
void precompute() {
fill(sieve + 2, sieve + N, 1);
for (int i = 2; i < N; i++) {
if (sieve[i]) {
for (int j = 1; i * j < N; j++) {
sieve[i * j] = 0;
prime[i * j] = i... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int n, m;
int a[100055], b[100055];
int have_a[10055], have_b[10055];
int nxt[10000055];
vector<int> on9_a[100055], on9_b[100055];
bool is_prime[10000055];
int main() {
scanf("%d %d", &n, &m);
for (int i = 2; i <= (int)1e7; i++) {
is_prime[i] = true;
}
for (int ... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int n, m, i, lp[10000001], a[100500][25], b[100500][25], k, x, ap[10000000],
bp[10000001], j, q, pr[10000001], kol = 0;
void step1() {
for (i = 2; i <= 10000000; i++) {
if (lp[i] == 0) {
lp[i] = i;
pr[++kol] = i;
}
for (j = 1; j <= kol && pr[j]... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution ... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
vector<long long> minDiv(1e7 + 1);
void esieve(long long s) {
for (int i = 2; i * i <= s; i++) {
if (!minDiv[i])
for (int k = i * i; k <= s; k += i) minDiv[k] = i;
}
}
vector<long long> primes(long long n) {
vector<long long> p;
while ... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
vector<string> split(const string &s, char c) {
vector<string> v;
stringstream ss(s);
string x;
while (getline(ss, x, c)) v.emplace_back(x);
return move(v);
}
template <typename T, typename... Args>
inline string arrStr(T arr, int n) {
stringstream s;
s << "["... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.*;
import java.util.*;
/*
* Heart beats fast
* Colors and promises
* How to be brave
* How can I love when I am afraid...
*/
//read the question correctly (is y a vowel? what are the exact constraints?)
//look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
//always declare multidime... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... |
import javax.jws.Oneway;
import java.io.*;
import java.math.BigInteger;
import static java.math.BigInteger.*;
import java.security.PublicKey;
import java.util.*;
public class Solution{
class C
{
int n;
int[]nums;
int[]pows;
int[][]r;
int[][]p;
public C(int n)... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class C
{
static class Scanner
{
BufferedReader br;
StringTokenizer st;... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int M = 1e7 + 5;
int prime[M];
void sieve() {
prime[1] = 1;
for (int i = 2; i < M; i++) prime[i] = i;
for (int i = 4; i < M; i += 2) prime[i] = 2;
for (int i = 3; i * i < M; i++) {
if (prime[i] == i) {
for (int j = i * i; j < M; j += i)
if (p... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int INF = 999999999;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;
bool is_prime[3163 + 5];
vector<long long> primes;
int num[450], den[450];
vector<pair<long long, int> > num_extra, den_extra;
void sieve() {
memset(is_prime, true, sizeof(is_p... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
inline void in(int &x) { scanf("%d", &x); }
inline void in(int &x, int &y) { scanf("%d %d", &x, &y); }
inline void in(int &x, int &y, int &z) { scanf("%d %d", &x, &y, &z); }
inline void out(int x) { printf("%d ", x); }
inline void... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int pw(int a, int b) {
int ans = 1;
for (int i = 1; i <= b; ++i) ans *= a;
return ans;
}
const int N = 100010;
map<int, int> ma, mb, m1, m2;
vector<pair<int, int> > a[N], b[N];
int pLst[4010], pCnt;
int main() {
int i, j, k;
int n, m;
for (i = 2; i <= 4000; ++i)... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import static java.lang.Math.*;
public class Solution implements Runnable {
static final int MAXN = 10000000;
public void solve () throws Exception {
boolean notprime [] = new boolean [MAXN + 1];
int n = nextInt();
int m = ... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... |
import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;
import static java.lang.String.*;
public class Main {
public static void main(String[] args) ... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int N = int(1e7) + 1;
int pr[N];
vector<int> primes;
int nr[int(1e5) + 1];
int dr[int(1e5) + 1];
map<int, int> myMap;
int main() {
ios::sync_with_stdio(false);
for (int i = 2; i <= N; i++) {
if (pr[i] == 0) {
primes.push_back(i);
pr[i] = i;
}
... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class C {
final int SIZE = 10001000;
//final int SIZE = 10000;
int[] factor = new int [SIZE+1]; // ���O�̑f����
int[] cntbo = new int [SIZE+1]; // ����̑f���̕p�x
int[] cntshi = new int [SIZE+1]; // ���q�̑f... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const int maxn1 = 1e7 + 5;
const ll mod = 998244353;
ll read() {
ll x = 0;
char ch = getchar();
bool flag = false;
if (ch == '-') {
flag = true;
ch = getchar();
}
while (ch < '0' || ch > '9') ch = getchar()... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public cla... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int maxint = -1u >> 2;
const double eps = 1e-6;
int n, m, a[100005], b[100005], aa[10000001], bb[10000001], i, j, k, t,
pp[3200], p[3200], pc;
int main() {
for (i = 0; i < 3200; ++i) pp[i] = 1;
pp[0] = 0;
pp[1] = 0;
for (i = 2; i < 3200; ++i) {
if (pp[... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 100010, maxe = 10000010;
int visit[maxe];
int N[2], S[2][maxn], W[2][maxe];
void get_prime() {
memset(visit, 0, sizeof(visit));
visit[1] = 1;
for (int i = 2; i < maxe; ++i)
if (visit[i] == 0) {
visit[i] = 1;
for (int k = 2; k * i < max... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
int n, m, x;
cin >> n >> m;
vector<int> N(n), M(m);
vector<int> v(1e7 + 1050);
v[1] = 1;
for (int i = 2; i < 1e7 + 100; i++) {
if (!v[i]) {
v[i] = i;
if (i < 1e4)
for (int j = i * i; j < 1e7 + ... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const uint32_t mod7 = uint32_t(1000000007);
const uint32_t mod9 = uint32_t(1000000009);
const int32_t inf31 = numeric_limits<int32_t>::max();
const uint32_t inf32 = numeric_limits<uint32_t>::max();
const int64_t inf63 = numeric_limits<int64_t>::max();
const uint64_t inf64 =... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
const int ub = 1e7 + 5;
int mf[ub + 1];
vector<int> ind[ub + 1];
vector<int> primes;
void init() {
f... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
bool done_something = false;
stringstream res;
res << "[";
for (; begin_iter != end_iter and counter; ++begin_iter) {
done_something = true;
counter--;
r... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
template <class T>
bool umin(T& a, const T& b) {
return b < a ? a = b, 1 : 0;
}
template <class T>
bool umax(T& a, const T& b) {
return a < b ? a = b, 1 : 0;
}
const int MOD = 998244353;
const long long inf = 1e18;
const long long mod = 1e9 + ... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int prime[10000005] = {0}, c1[10000005], c2[10000005];
int n, m, a[100005], b[100005];
void Prime() {
for (int i = 2; i < 10000005; i++) {
if (prime[i]) continue;
for (int j = 2; j * i < 10000005; j++) prime[i * j] = 1;
}
}
void split(int num, int c[]) {
for (... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int const N = 1e7;
int n, m, a, b, Start, End, arr[100100], brr[100100];
int Up[N + 10], Down[N + 10], P[N + 10];
int AA[100100], BB[100100];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
for (int i = 2; i <= N; i++)
if (!P[i]) {
P[i] = i;... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int MAXK = 1e7 + 7;
const double eps = 1e-9;
using namespace std;
int a[MAXN], b[MAXN];
int sieve[MAXK], cntA[MAXK], cntB[MAXK];
int main() {
for (int i = 2; i <= 10000000; i++)
i... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e7 + 1;
long long int spf[MAXN], num[MAXN] = {0}, denom[MAXN] = {0};
vector<long long int> prime;
long long int binpow(long long int a, long long int b) {
long long int res = 1;
while (b > 0) {
if (b & 1) res = res * a;
a = a * a;
b >>= 1;
... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
long long prime[10000010], n, m, cnt[10000010], a[100010], b[100010];
signed main() {
for (long long i = 2; i <= 10000001; i++) {
if (prime[i]) continue;
prime[i] = i;
for (long long j = 1ll * i * i; j <= 10000001; j += i) {
prime[j] = i;
}
}
sca... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T x) {
return x * x;
}
template <class T>
T gcd(T a, T b) {
return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
return (a / gcd<T>(a, b) * b);
}
template <class T>
inline T bigmod(T p, T e, T M) {
if (e == 0) retur... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
inline void getarrint0(vector<int>& a, int n, istream& in) {
for (int i = 0; i <= n - 1; i++) in >> a[i];
}
vector<int> linearSievePrimes(int upper) {
vector<int> lp(upper + 1, 0);
vector<int> primes;
for (int i = 2; i <= upper; i++) {
if (lp[i] == 0) {
lp... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
bool flag[10000002];
int res[10000002], tempa[100005], tempb[100005], a[100005], b[100005],
aa[10000002], bb[10000002], p1[10000002], p2[10000003];
int count1 = 0, count2 = 0;
void eritosfen() {
int i, j;
flag[1] = true;
flag[2] = true;
aa[2] = 0;
bb[2] = 0;
... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.*;
import java.util.*;
import java.math.*;
import java.util.*;
import java.lang.*;
public class Solution {
public static void main (String args[]) throws Exception {
Scanner cin = new Scanner(System.in);
PrintWriter cout = new PrintWriter(System.out);
int numerator[] = new int... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int n, m, x, a[((int)1e5) + 5], b[((int)1e5) + 5], c[((int)1e7) + 5][2], sq, t;
int h[((int)1e7) + 5];
int main() {
h[1] = 1;
h[2] = 2;
for (int i = 4; i <= ((int)1e7); i += 2) h[i] = 2;
sq = sqrt(((int)1e7)) + 1;
for (int i = 3; i <= ((int)1e7); i += 2)
if (!... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedLi... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int n, m;
int a[100005];
int b[100005];
bool flag[10005];
int prime[5000];
int cnt;
map<int, int> cnta;
map<int, int> cntb;
void findPrime() {
cnt = 0;
memset(flag, 0, sizeof(flag));
for (int i = 2; i <= 10000; i++) {
if (flag[i] == false) prime[++cnt] = i;
fo... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.Stack;
public class Main {
static BufferedReader br = new BufferedReader(new InputStr... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class C137 {
BufferedReader reader;
StringTokenizer tokenizer;
PrintWriter out;
public static int[] generateLeastFactor(int num) {
... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int prime[10000005] = {0}, c1[10000005], c2[10000005];
int n, m, a[100005], b[100005];
void Prime() {
for (int i = 2; i < 10000005; i++) {
if (prime[i]) continue;
for (int j = 2; j * i < 10000005; j++) prime[i * j] = 1;
}
}
void split(int num, int c[]) {
for (... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const long long INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e7 + 5;
long long n, m;
int a[N], b[N], cnta[N], cntb[N], minPrime[N];
map<lo... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int p[10000005];
int Fa[10000005], Fb[10000005];
int a[100005];
int b[100005];
void criba() {
for (int i = 2; i * i < 10000005; i++) {
if (!p[i])
for (int j = i * i; j < 10000005; j += i) p[j] = i;
}
for (int i = 2; i < 10000005; i++)
if (!p[i]) p[i] = i... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
vector<long long> lowestPrime;
map<int, int> ma, mb, gcd, gcd2;
long long binpow(long long b, long long p) {
long long res = 1;
while (p) {
if (p & 1) res = res * b;
b = b * b;
p >>= 1;
}
return res;
}
void criba(long long n) {
lowestPrime.resize(n + 5... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
const int MaxN = 100010, MaxAB = 10000010;
int N, M, a[MaxN], b[MaxN], A[MaxAB], B[MaxAB], prm[MaxAB];
void work(int N, int* a, int* A) {
for (int i = 1; i <= N; ++i) {
scanf("%d", a + i);
for (int j = a[i]; j > 1; j /= prm[j]) ++A[prm[j]];
}
}
void prt(int N, int* a, int* B) {
fo... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = (int)1e7 + 5;
const int lim = (int)1e7;
vector<int> smp(N), numerator(N), denominator(N), primes;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
for (long long int i = 2; i < N; i++) {
if (!smp[i]) {
... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
while (a && b) a > b ? a %= b : b %= a;
return a + b;
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long fast_exp(long long base, long long exp) {
long long res = 1;
while (exp > 0) {
if (exp % 2 == 1)
... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 1, Len = 1e5 + 1;
vector<int> p;
int a[Len], b[Len];
int mm[2][N];
int n, m;
void sieve() {
for (int i = 2; i < 3200; i++) {
bool prime = true;
for (int j = 2; j <= sqrt(i); j++)
if (i % j == 0) prime = false;
if (prime) p.push_back(i... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
int n, m, arr[10000005] = {}, isP[10000005], num[100005], den[100005], orig;
vector<int> p;
int main() {
for (int i = 0; i < 10000005; i++) isP[i] = 1;
isP[0] = 0;
isP[1] = 0;
for (int i = 0; i < 10000005; i++) {
if (isP[i])
for (int j = i + i; j < 1000000... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.*;
import java.util.*;
public class ReducingFractions {
public static void main(String[] args) throws IOException {
BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
StringTokenizer st = new StringTokenizer(rd.readLine());
N ... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
vector<int> a, b, ans1, ans2, pr, lp;
map<int, vector<int> > c, z;
long long const M = 10000000;
void resheto() {
for (int i = 2; i <= M; i++) {
if (lp[i] == 0) {
lp[i] = i;
pr.push_back(i);
}
int j = 0;
while (j < pr.size() && pr[j] <= lp[i] &... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Collections;
import java.util.ArrayList;
import java.io.InputStream;
/**
* @author Jenish... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | from collections import defaultdict
import bisect
from itertools import accumulate
import os
import sys
import math
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writabl... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
vector<int> prime;
bool mark[10000001];
int minp[10000001];
vector<int> pa[664580], pb[664580];
void getPrime() {
memset(minp, -1, sizeof(minp));
for (int i = 2; i < 10000001; i++)
if (!mark[i]) {
prime.push_back(i);
minp[i] = prime.size() - 1;
for... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 1;
map<int, int> toA, toB, pA, pB;
vector<int> A, B;
int nA, nB, x, fact[N];
void seive() {
memset(fact, -1, sizeof fact);
for (int i = 2; i < N; i++) {
if (fact[i] == -1) {
for (int j = i; j < N; j += i) fact[j] = i;
}
}
}
void facto... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.HashMap;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import ja... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
/**
* 111118315581
*
* -3 3 2 3 2 3 2 3 -3 3 -3 3 -3 3 2 3
*
* @author pttrung
*/
public class C {
public static long x, y, gcd;
public static int M... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | import java.util.*;
import java.io.*;
public class Solution
{
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader()
{
din = new DataInp... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
using namespace std;
long long fastexp(long long a, long long n, long long nod = LLONG_MAX) {
long long ans = 1;
while (n) {
if (n & 1) ans = (ans * a) % nod;
a = (a * a) % nod;
n >>= 1;
}
ret... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
long long pow(long long a, long long b, long long m) {
if (a == 0) return 0;
if (b == 0) return 1;
long long temp = pow(a, b / 2, m);
temp = ((temp % m) * (temp % m)) % m;
if (b & 1) temp = ((temp % m) * (a % m)) % m;
return temp;
}
long long string_to_num(strin... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
long long int spf[10000005], gum[100005], dum[100005];
map<long long int, long long int> a, b, g;
void inp(long long int n, map<long long int, long long int> &m,
long long int st[]) {
for (long long int i = 0; i < n; i++) {
scanf("%lld", &st[i]);
long lon... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:500000000")
using namespace std;
int d[10000009];
vector<int> V[10000009];
vector<int> ra, rb;
int A[100009], B[100009];
int main() {
int i, j, k;
for (i = 2; i * i <= 1e7; i++) {
if (d[i] == 0) {
d[i] = i;
for (j = 2 * i; j <= 1e7; j += i)
... |
Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned o... | #include <bits/stdc++.h>
using namespace std;
long long int MOD = 1e9 + 7;
long long int power(long long int a, long long int n) {
unsigned long long int result = 1, x = a;
while (n > 0) {
if (n % 2 == 1) result = (result * x) % MOD;
x = (x * x) % MOD;
n = n / 2;
}
return result;
}
long long int GCD... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.