output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> using namespace std; const int N = 600005; int base = 1000000 + 25; long long ans = 0; int pw[N + 5]; vector<int> divs; vector<int> g[505]; vector<int> H[505]; int F[N]; int val[N]; int h[N + 5]; int a[N]; int n; bool prime(int n) { for (int i = 2; i * i <= n; ++i) if (n % i == 0) return ...
### Prompt Create a solution in CPP for the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegment of ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a(2 * n); for (int i = 0; i < (n); ++i) { cin >> a[i]; a[n + i] = a[i]; } vector<int> maxa; vector<int> ds; long long ans = 0; vector<bool> covered(n, false...
### Prompt Construct a cpp code solution to the problem outlined: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegment ...
#include <bits/stdc++.h> using namespace std; template <class T> T sqr(T x) { return x * x; } const int maxn = 3e5 + 10; int n, s, g; long long ans; int a[maxn], b[maxn], c[maxn], d[maxn]; int GCD[maxn]; int gcd(int a, int b) { if (!b) return a; return gcd(b, a % b); } void calc(int g) { for (int i = 0; i <= g ...
### Prompt Please formulate a cpp solution to the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegme...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long powmod(long long a, long long b) { long long res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } int n, divN; vector<int> a; set<int> DIV; map<int, int> p; map...
### Prompt Please formulate a Cpp solution to the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegme...
#include <bits/stdc++.h> using namespace std; const int M = 200000; int n; int a[2 * M]; int gds[M]; int divs[500] = {0}; int nd = 0; int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } memcpy(a + n, a, sizeof(a))...
### Prompt In Cpp, your task is to solve the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegment of...
#include <bits/stdc++.h> using namespace std; const int N = 500001; int n; int a[N]; vector<int> g[N]; int c[N]; long long d[N]; bool used[N]; int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); for (...
### Prompt Create a solution in CPP for the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegment of ...
#include <bits/stdc++.h> using namespace std; int N, S[200000], CNT[200000], GCD[200000]; bool VIS[200000]; int gcd(const int &a, const int &b) { return b ? gcd(b, a % b) : a; } int main() { scanf("%d", &N); for (int i = 0; i < N; i++) scanf("%d", &S[i]); for (int i = 1; i < N; i++) GCD[i] = gcd(i, N); long lon...
### Prompt Your task is to create a Cpp solution to the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a su...
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 5; vector<int> v[N / 2]; int a[N], maxi[N]; int gdc(int x, int y) { if (x == 0) return y; return gdc(y % x, x); } int main() { int n, i, x, j, index, cc; cin >> n; for (i = 0; i < n; ++i) cin >> a[i], a[i + n] = a[i]; for (i = 1; i < n; ++i) ...
### Prompt Construct a Cpp code solution to the problem outlined: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegment ...
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 5; int a[N]; int gc[N]; int is_max[N]; int cnt[N]; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; for (int _n(n), i(0); i < _n; i++) { cin >> a[i]; a[i + n] = a[i]; } long long ans = 0; gc[0] = 0; for (int _n(n + ...
### Prompt Develop a solution in Cpp to the problem described below: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegme...
#include <bits/stdc++.h> using namespace std; int A[200005 << 1], n, ln[200005 << 1], C[200005 + 200005]; long long ans; bool mark[200005 << 1]; int Gcd(int a, int b) { return b ? Gcd(b, a % b) : a; } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &A[i]); A[i + n] = A[i]; } for ...
### Prompt Your challenge is to write a cpp solution to the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is ...
#include <bits/stdc++.h> const int maxn = 400010; using namespace std; int n, f[maxn], a[maxn], g[maxn], cnt[maxn]; long long ans; bool bo[maxn]; int gcd(int a, int b) { return !b ? a : gcd(b, a % b); } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i]), a[i + n] = a[i]; for (int d = 1; ...
### Prompt Your challenge is to write a Cpp solution to the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is ...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int n, v[200200], is[200200 * 2], su[200200], g[200200]; long long as; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &v[i]), g[i] = gcd(i, n); for (int i = 1; i <= n; i++) if (!(n % i...
### Prompt Your challenge is to write a CPP solution to the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is ...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10, maxk = 200; int n, a[maxn + 1]; void read() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", a + i); } } vector<int> b[maxk + 1]; int d[maxk + 1], tt = 0; int s1[maxn + 1], s[maxn + 1], sum, ok[maxn + 1]; long long ans = 0; ...
### Prompt Construct a Cpp code solution to the problem outlined: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegment ...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); } int main() { int n; cin >> n; int niza[n]; for (int ctr1 = 0; ctr1 < n; ctr1++) cin >> niza[ctr1]; vector<int> vek[n + 1]; for (int ctr1 = 1; ctr1 < n; ctr1++) vek[gcd(ctr1, n)].push_back(...
### Prompt In cpp, your task is to solve the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegment of...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7; int n, a[N], b[N], c[N], mx[N], gc[N]; int gcd(int a, int b) { return !b ? a : gcd(b, a % b); } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i]); for (int i = 1; i < n; i++) gc[i] = gcd(i, n); long long ans = 0; f...
### Prompt Generate a Cpp solution to the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegment of ar...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int n, v[200050], is[200050 * 2], su[200050], g[200050]; long long as; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &v[i]), g[i] = gcd(i, n); for (int i = 1; i <= n; i++) if (!(n % i...
### Prompt Please create a solution in Cpp to the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegme...
#include <bits/stdc++.h> using namespace std; int n[524288], mod[524288], m[524288], len[524288], cant[524288]; bool v[524288]; int gcd(int a, int b) { if (!b) return a; else return gcd(b, a % b); } int main() { int N, i, j, d, LEN; scanf("%d", &N); for (i = 0; i < N; i++) scanf("%d", &n[i]); for (i...
### Prompt Your task is to create a cpp solution to the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a su...
#include <bits/stdc++.h> using namespace std; vector<int> divisors(int n) { vector<int> divisors; divisors.reserve(n); for (int i = 1; i < n; ++i) { if (n % i == 0) { divisors.push_back(i); } } return divisors; } template <class T> T mod(T arg, T mod) { arg %= mod; if (arg < 0) { arg += ...
### Prompt Your task is to create a cpp solution to the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a su...
#include <bits/stdc++.h> using namespace std; const long long INF = 1 << 28; const long long LINF = 1ll << 61; inline long long getnum() { register long long r = 0; register bool ng = 0; register char c; c = getchar(); while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') ng = 1, c = getchar...
### Prompt Develop a solution in CPP to the problem described below: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegme...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:100000000") using namespace std; int gcd(int a, int b) { if (!a) return b; return gcd(b % a, a); } int mas[400400]; bool sum[400400]; int ost[400400]; int l[400400]; int canlen[400400]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { ...
### Prompt Construct a CPP code solution to the problem outlined: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegment ...
#include <bits/stdc++.h> using namespace std; array<int, 200000> a, m, sum, g; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int main() { ios::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 1; i < n; i++) g[i] = gcd(i, n); long long ans = 0; f...
### Prompt Create a solution in Cpp for the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegment of ...
#include <bits/stdc++.h> using namespace std; int arr[200005]; vector<int> vec[200005]; int crr[200005 << 1]; int f[200005 << 1]; int ma[200005]; int n; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", arr + i); } for (int i...
### Prompt Please create a solution in CPP to the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegme...
#include <bits/stdc++.h> using namespace std; long long rdtsc() { long long tmp; asm("rdtsc" : "=A"(tmp)); return tmp; } inline int myrand() { return abs((rand() << 15) ^ rand()); } inline int rnd(int x) { return myrand() % x; } const int INF = (int)1.01e9; const long double EPS = 1e-9; void precalc() {} const in...
### Prompt Construct a CPP code solution to the problem outlined: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegment ...
#include <bits/stdc++.h> const int maxn = 400010; using namespace std; int n, f[maxn], a[maxn], g[maxn], cnt[maxn]; long long ans; bool bo[maxn]; int gcd(int a, int b) { return !b ? a : gcd(b, a % b); } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i]), a[i + n] = a[i]; for (int d = 1; ...
### Prompt Construct a cpp code solution to the problem outlined: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegment ...
#include <bits/stdc++.h> using namespace std; int N; int A[200005]; vector<int> Max[200005], Aux[200005]; vector<int> Aux2[200005]; int Div[200005], cnt; void Read() { scanf("%d", &N); for (int i = 0; i < N; i++) { scanf("%d", &A[i]); } } void precalcDiv() { for (int i = 1; i <= N; i++) { if (N % i != 0...
### Prompt Develop a solution in CPP to the problem described below: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegme...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { long long r; while (b != 0) { r = a % b; a = b; b = r; } return a; } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } const int maxn = 200010; int n; int a[maxn]; bool state[maxn]; void solve...
### Prompt Develop a solution in cpp to the problem described below: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegme...
#include <bits/stdc++.h> using namespace std; bool rel_prime(int a, int b) { if (b == 0) return a == 1; return rel_prime(b, a % b); } int main() { int n; cin >> n; vector<int> nums(n, 0); int abs_max = 0; for (int i = 0; i < n; i++) { cin >> nums[i]; if (nums[i] > abs_max) abs_max = nums[i]; } ...
### Prompt Please formulate a CPP solution to the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegme...
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 10; int a[N], b[N], GCD[N], f[N], va[N]; inline int re() { int x = 0; char c = getchar(); bool p = 0; for (; c < '0' || c > '9'; c = getchar()) p |= c == '-'; for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0'; return p ? -x : x...
### Prompt Develop a solution in Cpp to the problem described below: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegme...
#include <bits/stdc++.h> using namespace std; int n, m; int A[201000], mark[201000], G[201000]; long long ans; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { scanf("%d", &n); for (int i = 0; i <= n; i++) G[i] = gcd(i, n); for (int i = 0; i < n; i++) scanf("%d", &A[i]); for (int t = 1; t < ...
### Prompt Generate a Cpp solution to the following problem: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≀ l < n, 1 ≀ s < n) of array a is an infinite periodic array with a period of length s that is a subsegment of ar...
#include <bits/stdc++.h> const int N = 1000 + 7; int n; double p[N][N], f[N], g[N], h[N][N]; int vis[N], top[N]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) scanf("%lf", p[i] + j), p[i][j] /= 100; vis[top[1] = n] = 1; for (int j = 1; j <= n; ++j) h[j][1] = 1 - p[j...
### Prompt Construct a Cpp code solution to the problem outlined: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need t...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1010; int N; double P[MAXN][MAXN]; double ans[MAXN]; double noout[MAXN]; bool vis[MAXN]; int main() { if (fopen("input.txt", "r")) { freopen("input.txt", "r", stdin); } scanf("%d", &N); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j+...
### Prompt Please formulate a CPP solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; bool out[maxn]; double p[maxn][maxn], d[maxn], cur_c[maxn], cur_p[maxn]; int n; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) for (int j = 1, x; j <= n; j++) scanf("%d", &x), p[i][j] = x / 100.0; for (int i = 1; i <= n; i++) d[i...
### Prompt Please create a solution in cpp to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; inline int read() { char c = getchar(); int x = 0; while (c < '0' || c > '9') { c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + (c ^ 48); c = getchar(); } return x; } int n; double c[1001][1001]; double p[1001]; double sum[1001]; doubl...
### Prompt Please formulate a Cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; int p[1005][1005]; double rem[1005]; double ans[1005]; double calcAns(int ind) { return (ans[ind] + rem[ind]) / (1 - rem[ind] + 1e-15); } int main() { ios::sync_with_stdio(false); int n; scanf("%d", &n); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) ...
### Prompt Please create a solution in cpp to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 5; int n; double g[N][N]; bool used[N]; double e[N], un[N]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) for (int j = 1, t; j <= n; j++) { scanf("%d", &t); g[i][j] = 1.0 * t / 100; } if (n == 1) return 0 & puts("0"...
### Prompt Please provide a CPP coded solution to the problem described below: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 a...
#include <bits/stdc++.h> const int maxn = 1005; const double INF = 2e9; using namespace std; double p[maxn][maxn], c[maxn], dp[maxn]; bool mark[maxn]; int main() { int n, x; scanf("%d", &n); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { scanf("%d", &x); p[i][j] = 0.01 * x; } fill...
### Prompt Create a solution in Cpp for the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to g...
#include <bits/stdc++.h> using namespace std; const int N = 1145; double g[N][N], pr[N], e[N], mn; int n, v[N]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf("%lf", &g[i][j]), g[i][j] /= 100; if (n == 1) { puts("0"); exit(0); } v[n] = 1; for (int i...
### Prompt Your challenge is to write a CPP solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 a...
#include <bits/stdc++.h> using namespace std; const double INF = 4e18; const int N = 3100; int n; double p[N][N]; double prob[N]; bool used[N]; double ans[N], sum[N]; int main() { srand(time(0)); cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { int x; scanf("%d", &x); ...
### Prompt In Cpp, your task is to solve the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to ...
#include <bits/stdc++.h> using namespace std; const int MN = 1011; double bad[MN], f[MN], p[MN][MN]; bool done[MN]; int n; int main() { ios ::sync_with_stdio(0); cin.tie(0); cout << (fixed) << setprecision(9); while (scanf("%d", &n) == 1) { for (int i = (1), _b = (n); i <= _b; ++i) for (int j = (1), _...
### Prompt Your task is to create a Cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and y...
#include <bits/stdc++.h> using namespace std; template <typename T> inline int Chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; } template <typename T> inline int Chkmin(T &a, T b) { return a > b ? a = b, 1 : 0; } inline void proc_status() { ifstream t("/proc/self/status"); cerr << string(istreambuf_iterator<ch...
### Prompt Please formulate a CPP solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T &num) { num = 0; bool w = 1; char c = getchar(); while (!isdigit(c)) { if (c == '-') w = 0; c = getchar(); } while (isdigit(c)) { num = num * 10 + c - '0'; ; c = getchar(); } num = w ? num : -num; ...
### Prompt Please create a solution in Cpp to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> int getch() { static const int len = 1 << 20; static char buf[len], *st, *ed; if (st == ed) ed = buf + fread(st = buf, 1, len, stdin); return st == ed ? EOF : *st++; } template <typename T> void read(T& x) { static int c; x = 0, c = getch(); while (isspace(c)) c = getch(); while...
### Prompt Develop a solution in cpp to the problem described below: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; double p[1111][1111], E[1111], son[1111], mo[1111]; int vst[1111]; int main() { int n, i, j; cin >> n; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { scanf("%lf", &p[i][j]); p[i][j] /= 100; } } for (i = 0; i < n; i++) E[i] = 1e9, mo[i] = 1...
### Prompt In cpp, your task is to solve the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to ...
#include <bits/stdc++.h> long long ago; using namespace std; template <class T = long long int> T nxt() { T x; cin >> x; return x; } long long int pw(long long int a, long long int b, long long int mod) { if (!b) return 1; if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod; return pw(a * a % mod, b / 2...
### Prompt Please create a solution in cpp to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; inline int read() { char ch = getchar(); int u = 0, f = 1; while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { u = (u << 1) + (u << 3) + ch - 48; ch = getchar(); } return u * f; } const int maxn = 1e3 + 10; con...
### Prompt Create a solution in CPP for the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to g...
#include <bits/stdc++.h> using namespace std; const int N = 1010; double dis[N], pr[N], di[N], p[N][N]; int n, vis[N]; int main() { cin >> n; cout << fixed << setprecision(12); for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) { int x; cin >> x; p[i][j] = x / 100.; } for (int i...
### Prompt Please formulate a Cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; int n; double p[1020][1020]; double m[1020], A[1020], B[1020]; bool vis[1020]; int dcmp(double x) { if (fabs(x) < 1e-12) return 0; return x < 0 ? -1 : 1; } int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { scanf("%...
### Prompt Generate a cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to get...
#include <bits/stdc++.h> using namespace std; inline long long read() { char ch = getchar(); long long s = 0, w = 1; while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { s = s * 10 + ch - '0'; ch = getchar(); } return s * w; } inline int ...
### Prompt Your challenge is to write a Cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 a...
#include <bits/stdc++.h> using namespace std; long long inp[1005][1005]; vector<bool> visited(1005); vector<long double> score(1005); int main() { long long n; cin >> n; for (long long i = 0; i < (n); ++i) { for (long long j = 0; j < (n); ++j) { cin >> inp[i][j]; } } for (long long i = 0; i < (n...
### Prompt Please create a solution in Cpp to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; const int maxn = 2010; int n; double G[maxn][maxn]; int vis[maxn]; double f[maxn], s[maxn]; int ri() { int s = 0, w = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') w = -1; c = getchar(); } while (c >= '0' && c <= '9') { s = (s << 1)...
### Prompt Create a solution in cpp for the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to g...
#include <bits/stdc++.h> using namespace std; template <class T> inline void upmax(T& a, T b) { if (a < b) a = b; } template <class T> inline void upmin(T& a, T b) { if (a > b) a = b; } const int maxn = 1007; const int maxm = 200007; const int mod = 1000000007; const int inf = 0x7fffffff; const double eps = 1e-7; t...
### Prompt Your challenge is to write a cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 a...
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> std::istream& operator>>(std::istream& i, pair<T, U>& p) { i >> p.first >> p.second; return i; } template <typename T> std::istream& operator>>(std::istream& i, vector<T>& t) { for (auto& v : t) { i >> v; } return i; } templat...
### Prompt Please formulate a CPP solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; const int N = 1010; int s[N][N]; bool w[N], us[N]; double p[N], f[N], g[N]; inline int gi() { int x = 0, o = 1; char ch = getchar(); while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar(); if (ch == '-') o = -1, ch = getchar(); while (ch >= '0' && ch <= '9') x...
### Prompt Develop a solution in CPP to the problem described below: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; int n, ta; long double x[1005][1005], tb, tc, td; vector<int> y; vector<long double> z; bool used[1005]; int main() { scanf("%d", &n); for (int a = 0; a < n; a++) for (int b = 0; b < n; b++) { scanf("%d", &ta); x[a][b] = ta; x[a][b] /= 100; } ...
### Prompt Generate a Cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to get...
#include <bits/stdc++.h> using namespace std; const int N = 1013; double p[N][N], f[N], g[N]; bool done[N]; int n; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) { scanf("%lf", &p[i][j]); p[i][j] *= 0.01; } for (int i = 1; i < n; ++i) f[i] = g[i] = 1.0;...
### Prompt Construct a cpp code solution to the problem outlined: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need t...
#include <bits/stdc++.h> using namespace std; const int MN = 1005, inf = 1000000005, mod = 1000000007; const long long INF = 1000000000000000005LL; double pstwo[MN][MN], A[MN], B[MN], W[MN]; int done[MN]; priority_queue<pair<double, int> > Q; int n; void dij() { Q.push({0.0, n}); while (!Q.empty()) { int cur = ...
### Prompt Create a solution in Cpp for the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to g...
#include <bits/stdc++.h> const int inf = 0x3f3f3f3f, Inf = 0x7fffffff; const long long INF = 0x7fffffffffffffff; const double eps = 1e-10; template <typename _Tp> _Tp gcd(const _Tp &a, const _Tp &b) { return (!b) ? a : gcd(b, a % b); } template <typename _Tp> __inline__ __attribute__((always_inline)) _Tp abs(const _T...
### Prompt Generate a CPP solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to get...
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &x) { x = 0; int f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } x *= f; } inline void write(int x) {...
### Prompt Develop a solution in CPP to the problem described below: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; const int maxN = 1 << 10; const long double INF = 1e30; long double dist[maxN], p[maxN], P[maxN][maxN]; bool juz[maxN]; long double eval(int v) { if (p[v] > 0.99999) return INF; return (dist[v] + p[v]) / (1.0 - p[v]); } void solve() { int...
### Prompt In cpp, your task is to solve the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to ...
#include <bits/stdc++.h> using namespace std; template <class T> T sqr(T x) { return x * x; } const int maxn = 1050; int p[maxn][maxn]; double a[maxn], b[maxn]; int vis[maxn], inf[maxn], n, m; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf("%d", &p[i][j]); for ...
### Prompt Develop a solution in Cpp to the problem described below: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; const int N = 2020; int n, a[N]; bool vis[N]; double p[N][N], f[N], g[N], pr[N]; int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + c...
### Prompt Develop a solution in Cpp to the problem described below: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; int read() { int a = 0; bool opt = 0; char c = getchar(); while (c < '0' || c > '9') opt |= c == '-', c = getchar(); while (c >= '0' && c <= '9') a = (a << 3) + (a << 1) + (c ^ 48), c = getchar(); return opt ? -a : a; } int n, num, vis[1005]; double f[1005],...
### Prompt Construct a cpp code solution to the problem outlined: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need t...
#include <bits/stdc++.h> const int MaxN = 1e3 + 10; int n, vis[MaxN], a[MaxN]; double p[MaxN][MaxN], d[MaxN], sum[MaxN], pr[MaxN]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { int now = 0; sum[i] = pr[i] = 1.0; for (int j = 1; j <= n; j++) scanf("%d", &now), p[i][j] = now * 0.01L; } ...
### Prompt Generate a CPP solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to get...
#include <bits/stdc++.h> using namespace std; const int N = 1010, INF = 0x3f3f3f3f; template <class T> void read(T &x) { x = 0; char c = getchar(); while (!isdigit(c)) c = getchar(); while (isdigit(c)) x = x * 10 + c - 48, c = getchar(); } void file() {} double p[N][N]; int n; int a[N]; void init() { read(n);...
### Prompt Develop a solution in Cpp to the problem described below: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; double Inf = 1e50; const int Maxn = 1020; double d[Maxn]; bool done[Maxn]; int n; int pro[Maxn][Maxn]; double nowp[Maxn], nowval[Maxn]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) scanf("%d", &pro[i][j]); } for (int ...
### Prompt Please create a solution in cpp to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; int n, i, j; double f[1002], p[1002][1002], p1[1002]; bool vis[1002]; int read() { char c = getchar(); int w = 0; while (c < '0' || c > '9') c = getchar(); while (c <= '9' && c >= '0') { w = w * 10 + c - '0'; c = getchar(); } return w; } int main() { n...
### Prompt Generate a Cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to get...
#include <bits/stdc++.h> using namespace std; template <class T> inline bool checkMax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } template <typename T, typename... Args> inline void checkMax(T &a, const Args... arg) { checkMax(a, max(arg...)); } template <class T> inline bool checkMin(T &a, const T &b) { r...
### Prompt Please create a solution in Cpp to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; int n; long double p[1005][1005]; long double E[1005]; long double prob[1005]; bool bio[1005]; int pp[1005][1005]; int main() { cin >> n; for (int i = (int)(0); i < (int)(n); ++i) for (int j = (int)(0); j < (int)(n); ++j) scanf("%d", pp[i] + j), p[i][j] = pp[i...
### Prompt Please formulate a cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> const int N = 2005; double p[N][N], dis[N], pre[N]; int n, vis[N]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf("%lf", &p[i][j]), p[i][j] = p[i][j] / 100; if (n == 1) { puts("0"); return 0; } for (int i = 1; i < n; i++...
### Prompt Develop a solution in CPP to the problem described below: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; inline long long getint() { long long _x = 0, _tmp = 1; char _tc = getchar(); while ((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar(); if (_tc == '-') _tc = getchar(), _tmp = -1; while (_tc >= '0' && _tc <= '9') _x *= 10, _x += (_tc - '0'), _tc = getchar();...
### Prompt Develop a solution in Cpp to the problem described below: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma G++ optimize(2) using namespace std; char nc() { return getchar(); } int read() { int x = 0, y = 1; char c = nc(); while (!isdigit(c)) { if (c == '-') y = -1; c = nc(); } while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = nc();...
### Prompt Generate a Cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to get...
#include <bits/stdc++.h> using namespace std; const long long N = 400005; long long n, d[1005], vis[1005] = {0}; double p[1005][1005], ans[1005], sum[1005], mul[1005]; int main() { ios::sync_with_stdio(false); scanf("%lld", &n); for (long long i = 1; i <= n; i++) { for (long long j = 1; j <= n; j++) { s...
### Prompt Your task is to create a Cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and y...
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; inline int gi() { char c = getchar(); while (c < '0' || c > '9') c = getchar(); int sum = 0; while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar(); return sum; } int n; double p[maxn][maxn], dis[maxn], P[maxn]; int vis[maxn]; i...
### Prompt Please formulate a CPP solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; inline long long read() { register long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { x = (x << 3) + (x << 1) + ch - '0'; ch = getchar(); } return (f == 1) ? x : -x...
### Prompt Generate a Cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to get...
#include <bits/stdc++.h> using namespace std; int n; int p[1013][1013]; bool done[1013]; double ans[1013]; double tot[1013]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) scanf("%d", &p[i][j]); for (int i = 0; i < n; i++) { ans[i] = 1 / 0.; tot[i] = 1; } ans...
### Prompt Please create a solution in cpp to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; const int N = 1010; double f[N], c[N]; int a[N][N], n; int d[N], l, r, vis[N]; int main() { cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { scanf("%d", &a[i][j]); } c[i] = 1; } d[++r] = n; vis[n] = 1; for (int i = 1; i <...
### Prompt Please formulate a cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; inline int read() { char ch = getchar(); int nega = 1; while (!isdigit(ch)) { if (ch == '-') nega = -1; ch = getchar(); } int ans = 0; while (isdigit(ch)) { ans = ans * 10 + ch - 48; ch = getchar(); } if (nega == -1) return -ans; return ans...
### Prompt Develop a solution in CPP to the problem described below: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; const int N = 1005; int n, vis[N]; double p[N][N], A[N], B[N]; double dis(int u) { return B[u] < 1 ? A[u] / (1 - B[u]) : 1e9; } int main() { cin >> n; for (int i = (1); i <= (n); i++) for (int j = (1); j <= (n); j++) scanf("%lf", &p[i][j]), p[i][j] /= 100; for (in...
### Prompt Construct a CPP code solution to the problem outlined: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need t...
#include <bits/stdc++.h> using namespace std; const long long inf = 1505 * 1505, df = 1505; double a[df], b[df], dis[df][df], sum[df][df]; long long n, vis[df]; inline long long read() { long long x = 0, y = 1; char ch = getchar(); while (ch > '9' || ch < '0') y = (ch == '-') ? -1 : 1, ch = getchar(); while (ch...
### Prompt Develop a solution in CPP to the problem described below: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; const long long nr = 2010; inline long long read() { long long ret = 0; long long x = 1; char ch; ch = getchar(); while (!isdigit(ch)) { if (ch == '-') x = -1; ch = getchar(); } while (isdigit(ch)) { ret = ret * 10 + ch - '0'; ch = getchar(); ...
### Prompt Develop a solution in Cpp to the problem described below: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; const double inf = 1e15; int n, p[1050][1050]; double val[1050], A[1050], B[1050]; bool vis[1050]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf("%d", &p[i][j]); for (int i = 1; i <= n - 1; i++) val[i] = inf; val[n...
### Prompt Develop a solution in CPP to the problem described below: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; const int N = 1005; int n, a[N][N]; double dis[N], e[N], p[N]; bool vis[N]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) scanf("%d", a[i] + j); fill(dis, dis + n, 1e9); for (int i = 1; i <= n; ++i) { int u = 0; ...
### Prompt Your challenge is to write a Cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 a...
#include <bits/stdc++.h> const double INF = 1e8; const int N = 1003; int n, g[N][N], used[N]; double d[N], t[N]; int main() { int u, v; scanf("%d", &n); for (u = 1; u <= n; u++) for (v = 1; v <= n; v++) scanf("%d", &g[u][v]); for (u = 1; u <= n; u++) d[u] = INF; d[n] = 0; for (int j = 1; j <= n; j++) { ...
### Prompt Construct a cpp code solution to the problem outlined: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need t...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007LL; int n; double p[1000 + 3][1000 + 3]; double r[1000 + 3]; double a[1000 + 3]; double b[1000 + 3]; bool done[1000 + 3]; int main() { scanf("%d", &n); for (int i = 0, _n = n; i < _n; i++) for (int j = 0, _n = n; j < _n; j++) scanf("%...
### Prompt Your task is to create a cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and y...
#include <bits/stdc++.h> using namespace std; inline int read() { int f = 1, ans = 0; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { ans = ans * 10 + c - '0'; c = getchar(); } return f * ans; } const int MAXN = 1e3 + 1...
### Prompt Please provide a Cpp coded solution to the problem described below: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 a...
#include <bits/stdc++.h> using namespace std; const int N = 1010; int n, f[N]; double p[N][N], s[N], E[N]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf("%lf", &p[i][j]), p[i][j] /= 100.0; for (int i = 1; i < n; i++) E[i] = 1, s[i] = 1.0 - p[i][n]; f[n] = 1; ...
### Prompt Construct a cpp code solution to the problem outlined: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need t...
#include <bits/stdc++.h> using namespace std; const int N = 1010; int n, p[N][N], vis[N]; long double E[N], prob[N], coef[N]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) scanf("%d", &p[i][j]); for (int i = 0; i < n; i++) E[i] = 1e30, prob[i] = 1, coef[i] = 0; E[n - ...
### Prompt Your task is to create a Cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and y...
#include <bits/stdc++.h> using namespace std; const long long linf = 1e18 + 5; const int mod = (int)1e9 + 7; const int logN = 18; const int inf = 1e9; const int N = 1005; int n, m, x, y, z, t; double all[N], prob[N], arr[N][N], SP[N]; int h[N]; void dijkstra() { priority_queue<pair<double, int>, vector<pair<double, i...
### Prompt Your challenge is to write a Cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 a...
#include <bits/stdc++.h> using namespace std; bool vis[1005]; double p[1005][1005], now[1005], e[1005]; int read() { int A; bool K; char C; C = A = K = 0; while (C < '0' || C > '9') K |= C == '-', C = getchar(); while (C > '/' && C < ':') A = (A << 3) + (A << 1) + (C ^ 48), C = getchar(); return (K ? -A :...
### Prompt Your challenge is to write a CPP solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 a...
#include <bits/stdc++.h> using namespace std; const int Maxx = 1000005, Mod = 998244353; inline int read() { int res = 0, bj = 0; char ch = getchar(); while (ch < '0' || ch > '9') bj |= (ch == '-'), ch = getchar(); while (ch >= '0' && ch <= '9') res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar(); r...
### Prompt Please provide a cpp coded solution to the problem described below: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 a...
#include <bits/stdc++.h> using namespace std; template <class T> inline void chkmin(T &a, T b) { if (a > b) a = b; } template <class T> inline void chkmax(T &a, T b) { if (a < b) a = b; } inline int read() { int s = 0, f = 1; char ch = getchar(); while (!isdigit(ch) && ch != '-') ch = getchar(); if (ch == '...
### Prompt Create a solution in cpp for the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to g...
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> void ckmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> void ckmax(T1 &a, T2 b) { if (a < b) a = b; } int read() { int x = 0, f = 0; char ch = getchar(); while (!isdigit(ch)) f |= ch == '-', ch = getcha...
### Prompt Please provide a Cpp coded solution to the problem described below: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 a...
#include <bits/stdc++.h> using namespace std; const int N = 1005; int v[N], n; double d[N], te[N], a[N][N]; int main() { scanf("%d", &n); if (n == 1) return 0 * puts("0"); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) { int x; scanf("%d", &x); a[i][j] = 0.01 * x; } for (int...
### Prompt In cpp, your task is to solve the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to ...
#include <bits/stdc++.h> using namespace std; const int Max_N(1050); int N; double P[Max_N][Max_N], F[Max_N], G[Max_N], V[Max_N]; bool done[Max_N]; int main() { scanf("%d", &N); for (int i = 1; i <= N; ++i) { V[i] = 1.0; for (int j = 1; j <= N; ++j) scanf("%lf", P[i] + j), P[i][j] /= 100.0; if (i < N) F...
### Prompt In CPP, your task is to solve the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to ...
#include <bits/stdc++.h> using namespace std; template <class T> inline bool getmin(T *a, const T &b) { if (b < *a) { *a = b; return true; } return false; } template <class T> inline bool getmax(T *a, const T &b) { if (b > *a) { *a = b; return true; } return false; } template <class T> inlin...
### Prompt Please create a solution in cpp to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double EPS = 1e-10; inline int read() { static char ch; bool sgn = false; while (ch = getchar(), ch < '0' || ch > '9') if (ch == '-') sgn = true; int res = ch - 48; while (ch = getchar(), ch >= '0' && ch <= '9') res = res * ...
### Prompt Create a solution in cpp for the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to g...
#include <bits/stdc++.h> using namespace std; const int N = 1005; template <typename T> void read(T &x) { x = 0; int f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = -1; for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + c - '0'; x *= f; } int n; double g[N][N]; d...
### Prompt Your challenge is to write a Cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 a...
#include <bits/stdc++.h> using namespace std; int n; double p[1006][1006]; double dp[1006], tmp[1006], f[1006]; int vis[1006]; int main() { cin >> n; for (int i = 1; i <= n; ++i) for (int j = 1, q; j <= n; ++j) scanf("%d", &q), p[i][j] = 1.0 * q / 100; for (int i = 1; i <= n; ++i) dp[i] = 3e18, tmp[i] = 1; ...
### Prompt In Cpp, your task is to solve the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to ...
#include <bits/stdc++.h> using namespace std; int n; int mat[1003][1003]; double f[1003], p[1003]; bool vis[1003]; bool cmp(int, int); int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { p[i] = 1; for (int j = 1; j <= n; ++j) scanf("%d", mat[i] + j); } f[n] = p[n] = 0; while (true) { int ...
### Prompt Your challenge is to write a cpp solution to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 a...
#include <bits/stdc++.h> using namespace std; const int N = 1002; int n, m, q[N], vis[N]; double p[N][N], f[N], prod[N], sum[N]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { int x; scanf("%d", &x); p[i][j] = x / 100.0; } prod[i] = 1; } ...
### Prompt Please create a solution in CPP to the following problem: The scientists have recently discovered wormholes β€” objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you nee...