Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = "RDLU"; long long ln, lk, lm; void etp(bool f = 0) { puts(f ? "YES" : "NO"); exit(0); } void addmod(int &x, int y, int mod = 1000000007) { assert(y >= 0); x += y; if (x >...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; template <typename T> inline void read(T &AKNOI) { T x = 0, flag = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') flag = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; map<long long, long long> mp; long long a[55], b[55], m[55]; bool prime[40005]; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long extgcd(long long a, long long b, long long &x, long long &y) { if (b == 0) { x = 1, y ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; char getc() { char c = getchar(); while ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9')) c = getchar(); return c; } long long gcd(long long n, long long m) { return m == 0 ? n : gcd(m, n % m); } long long read() { long long x = 0, f = 1; ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 100; vector<int> v; vector<int> vp; int a[N][20], f[N], invf[N]; int n, p, l, r; bool vis[N]; int qpow(int x, int b) { long long sum = 1; long long now = x; while (b) { if (b & 1) sum = sum * now % p; now = now * now % p; b >>= 1; } ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; template <typename T> inline void cmax(T &x, T y) { y > x ? x = y : 0; } template <typename T> inline void cmin(T &x, T y) { y < x ? x = y : 0; } int mod, ss; inline int add(long long a, long long b) { a += b; return a >= mod ? a - mod : a; } inline int pop(long lon...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> const int N = 100050; using namespace std; inline int gi() { char ch = getchar(); int x = 0, q = 0; while (ch < '0' || ch > '9') ch == '-' ? q = 1 : 0, ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return q ? (-x) : x; } int fap(int a, int b, in...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } template <class T> inline void gn(T &first) { char c, sg = 0; while (c = getchar(), (c > '9' || c ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const long double pi = acosl(-1); const int maxn = 100010; const long long mod = 1e9 + 7; const int inf = 1e9; const long double eps = 1e-10; int n, l, r; long long p, fac[maxn], inv[maxn]; vector<pair<int, int> > vec; long long phi; long long pwr(long long x, long long P) ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:512000000") using namespace std; void solve(bool); void precalc(); clock_t start; int main() { start = clock(); int t = 1; cout.sync_with_stdio(0); cin.tie(0); precalc(); cout.precision(10); cout << fixed; int testNum = 1; while (t--) { solv...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int P = 10, N = 1e5 + 10; int inverse(int a, int m) { if (a <= 1) return a; int ans = (1 - (long long int)inverse(m % a, a) * m) / a; if (ans < 0) ans += m; return ans; } int fact[N], ifact[N], pot[N][P]; vector<int> primes(int n) { vector<int> ans; for (i...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Random; import java.util.Map; import java.io.OutputStreamWriter; import java.io.OutputStream; import java.util.Iterator; import java.util.Set; import java.io.IOException; import java.io.Unchec...
JAVA
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; long long inv[100007], fac[100007], p[100007], t[100007][20]; int n, l, r, P, tot, Phi; int phi(int k) { int i, s; s = k; for (i = 2; i * i <= k; i++) { if (k % i == 0) s = s / i * (i - 1); while (k % i == 0) k /= i; } if (k > 1) s = s / k * (k - 1); ret...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 1; char ch = getchar(); while (ch > '9' || ch < '0') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } const long ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; int n; long long P; int l, r; long long fpow(long long a, long long b) { long long ans = 1, t = a; while (b) { if (b & 1) ans = ans * t % P; t = t * t % P; b >>= 1; } return ans; } void exgcd(long long a, long long b, long long& x, long long& y) { if (...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 100003; int n, L, R, phi; long long mod; long long fac[N], inv[N]; int d[N][33]; int tot, p[N]; long long fpow(long long x, int y) { long long res = 1; while (y) { if (y & 1) res = res * x % mod; x = x * x % mod; y >>= 1; } return res; } vo...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 100000 + 10; int n, p, l, r; long long fc[N], ifc[N]; void exgcd(long long a, long long b, long long &d, long long &x, long long &y) { if (!b) return x = 1, y = 0, d = a, void(); exgcd(b, a % b, d, y, x); y -= a / b * x; } long long inv(long long a, long...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 100005; long long p, n, l, r; long long pr[N], inv[N], f[N], c[N][40], phi; int cnt = 0; long long powe(long long a, long long b) { long long base = 1; while (b) { if (b & 1) base = (base * a) % p; a = (a * a) % p; b >>= 1; } return base; }...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> inline void read(long long &x) { static char c; for (c = getchar(); !('0' <= c && c <= '9'); c = getchar()) ; for (x = 0; ('0' <= c && c <= '9'); c = getchar()) x = x * 10 + c - 48; } using namespace std; void write(long long x) { if (x < 10) { putchar('0' + x); return; } ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; long long shin[25]; long long seto(void); void ayano(long long x, char spliter = '\n'); int p, phip, phipm; int prims[10], primdeg[10], primcnt = 0; int kasumi(int a, int b); int comb(int a, int b); struct Num { int x, xinv, degs[10]; Num(void) : x(1), xinv(1) { for...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int MM = 1e9 + 7; const double eps = 1e-8; const int MAXN = 1e5 + 10; int n, m; void prework() {} void read() {} long long A[MAXN][11], B[MAXN][11], C[MAXN][11]; long long P; vector<pair<int, int> > pm; long long pw(long long p, long long q, long long MM) { long lon...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
import java.io.*; import java.util.*; public class D896 { long mod; long[][] factorial(int n, Long[] prime) { int k = prime.length; long[][] f = new long[n+1][k+1]; f[0][0] = 1L; for(int i = 1; i <= n; i++) { long cur = i; for(int j = 0; j <= k; j++) f[i][j] = f[i-1][j]; for(int j = 0; j < k; j+...
JAVA
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; template <typename S, typename T> ostream& operator<<(ostream& out, pair<S, T> const& p) { out << '(' << p.first << ", " << p.second << ')'; return out; } template <typename T> ostream& operator<<(ostream& out, vector<T> const& v) { int l = v.size(); for (int i = 0;...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> template <typename T> inline void read(T &x) { x = 0; char c = getchar(); bool flag = false; while (!isdigit(c)) { if (c == '-') flag = true; c = getchar(); } while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar(); if (flag) x = -x; } using namespace std; int n, mod, l, r...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
import java.util.*; /** * Created by mcl on 2017/12/2. */ public class Main { public static void main(String[] args) { new Main().cal(); } int n; int p; int left; int right; long[][] fact = null; List<Integer[]> list = new ArrayList<>(); void cal() { Scanner in = new Scanner(System.in);...
JAVA
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; long long factorial_invertible[100001]; int factor[100001], p; const int MAX_BAD = 17; int idx_bad[100001]; int pow_bad[MAX_BAD][100001]; int factorial_bad[100001][MAX_BAD]; vector<int> bad_factors; struct t { long long a, b; int g; t(long long a, long long b, int g) ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; long long n, m, mod, l, r, ans, fac[100005], inv[100005], a[100005][20], p[100005]; long long kp(long long a, long long b, long long p) { if (!b) return 1; long long c = kp(a, b >> 1, p); c = c * c % p; if (b & 1) c = c * a % p; return c; } long long c(long lo...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; inline int read() { int w = 0, x = 0; char c = getchar(); while (!isdigit(c)) w |= c == '-', c = getchar(); while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar(); return w ? -x : x; } namespace star { const int maxn = 1e5 + 10; int p, n, l, r, tot; int pn[40], i...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, l, r, p, prime[20], cnt; long long power(long long x, long long y) { long long ans = 1; for (; y; y >>= 1, x = (long long)x * x % p) if (y & 1) ans = (long long)ans * x % p; return ans; } void exgcd(long long a, long long b, long lon...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; long long inv[100010], fac[100010], p[100010], t[100010][20]; int n, l, r, P, tot, Phi; int phi(int k) { int i, s; s = k; for (i = 2; i * i <= k; i++) { if (k % i == 0) s = s / i * (i - 1); while (k % i == 0) k /= i; } if (k > 1) s = s / k * (k - 1); ret...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; template <class T> ostream& operator<<(ostream& stream, const vector<T> v) { stream << "[ "; for (int i = 0; i < (int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream; } long long fpow(long long x, long long p, long long m) { long long r = 1; f...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
import java.util.*; /** * Created by mcl on 2017/12/2. */ public class Main { public static void main(String[] args) { new Main().cal(); } int n; int p; int left; int right; long[] fact = null; int[] primes = null; void init() { primes = split(p); fact = new long[n + 1]; fact[0] ...
JAVA
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int sz = 1e5 + 10; int mod, m, ef = 1; int f[sz][12], f2[sz], st[sz][12]; int po(int x, int y) { int re = 1 % mod; while (y) { if (y & 1) re = (1ll * re * x) % mod; x = (1ll * x * x) % mod; y >>= 1; } return re; } int fc(int n, int k) { int re = ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, p, l, r, phi, cp[20], num[N][20], tot, ans, f[N], ny[N]; inline int read() { int x, f = 1; char ch; while (!(isdigit(ch = getchar()))) ch == '-' ? f = -1 : f; x = ch ^ 48; while ((isdigit(ch = getchar()))) x = (x << 1) + (x << 3) + (c...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } const int MAXN = 100000; int n, MOD, l, r; int egcd(int x, int y, int &a, int &b) { if (y == 0) { a = 1, b = 0; return x; } int g = egcd(y, x % y, b, a); b -= a * (x / y); retur...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int c = 200002, k = 30; long long n, mod, mod2, l, r; long long cnt, pr[k], t[k], fakt[c][k], sum = 0; int phi(int n) { int result = n; for (int i = 2; i * i <= n; i++) { if (n % i == 0) { pr[++cnt] = i; while (n % i == 0) n /= i; result -= r...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; long long inv[100010], fac[100010], p[100010], t[100010][20]; int n, l, r, P, tot, Phi; int phi(int k) { int i, s; s = k; for (i = 2; i * i <= k; i++) { if (k % i == 0) s = s / i * (i - 1); while (k % i == 0) k /= i; } if (k > 1) s = s / k * (k - 1); ret...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; map<int, int> M; vector<pair<int, int> > V; long long F1[12][100010], F2[12][100010]; int p; int pw(int x, int y, int M) { int res = 1; while (y) { if (y & 1) res = (long long)res * x % M; x = (long long)x * x % M; y >>= 1; } ret...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; long long inv[100010], fac[100010], p[100010], t[100010][20]; int n, l, r, P, tot, Phi; int phi(int k) { int i, s; s = k; for (i = 2; i * i <= k; i++) { if (k % i == 0) s = s / i * (i - 1); while (k % i == 0) k /= i; } if (k > 1) s = s / k * (k - 1); ret...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; using VS = vector<string>; using LL = long long; using VI = vector<int>; using VVI = vector<VI>; using PII = pair<int, int>; using PLL = pair<LL, LL>; using VL = vector<LL>; using VVL = vector<VL>; const int INF = 1e9; const LL LINF = 1e16; const LL MOD = 1000000007; const ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; inline int rd() { char ch = getchar(); int i = 0, f = 1; while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { i = (i << 1) + (i << 3) + ch - '0'; ch = getchar(); } return i * f; } const int Maxn = 1e5 + 50; vect...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; template <class T> void splitstr(const string &s, vector<T> &out) { istringstream in(s); out.clear(); copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out)); } static void redirect(int argc, const char **argv) { ios::sync_with_stdio(false); cin.t...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; void Gcd(long long x, long long y, long long mod, long long& kx, long long& ky) { if (y == 0) return void(kx = ky = 1); long long del = x / y; Gcd(y, x - del * y, mod, ky, kx); (ky -= del * kx) %= mod; } long long Oem(long long x, long long mod) { long lo...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int Imx = 2147483647; const long long Lbig = 2e18; int mod; struct fastio { char s[100000]; int it, len; fastio() { it = len = 0; } inline char get() { if (it < len) return s[it++]; it = 0; len = fread(s, 1, 100000, stdin); if (len == 0) ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 100005; long long p, n, l, r; long long pr[N], inv[N], f[N], c[N][40], phi; int cnt = 0; long long powe(long long a, long long b) { long long base = 1; while (b) { if (b & 1) base = (base * a) % p; a = (a * a) % p; b >>= 1; } return base; }...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const long long int inf = 1000000000; const long long int mod = 1000000000 + 7; inline void IO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } inline int dcmp(long double x) { return x < -1e-12 ? -1 : (x > 1e-12); } template <class T> inline int CHECK(T M...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 100003; int n, L, R, phi; long long mod; long long fac[N], inv[N]; int d[N][33]; int tot, p[N]; long long fpow(long long x, int y) { long long res = 1; while (y) { if (y & 1) res = res * x % mod; x = x * x % mod; y >>= 1; } return res; } vo...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class t, class u> void chmax(t& first, u second) { if (first < second) first = second; } template <class t, class u> void chmin(t& first, u second) { if (second < first) first = second; } template <class t> using vc = vector<t>; template ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const long long inf = 1e9; const long long Inf = 1e18; const long long N = 1e5 + 10; long long mod; long long gi() { long long x = 0, o = 1; char ch = getchar(); while ((ch < '0' || ch > '9') && ch != '-') ch = getchar(); if (ch == '-') o = -1, ch = getchar(); whi...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool upmin(T &x, T y) { return y < x ? x = y, 1 : 0; } template <typename T> inline bool upmax(T &x, T y) { return x < y ? x = y, 1 : 0; } const long double eps = 1e-11; const long double pi = acos(-1); const long long oo = 1 << 30; const lo...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int maxN = 2e5 + 10, lim = 2e5; int n, P, l, r, phi; int fac[maxN + 1], inv[maxN + 1]; int cnt, p[maxN + 1], c[maxN + 1][22]; inline long long ADD(long long x, long long y) { return x + y >= P ? x + y - P : x + y; } inline long long SUB(long long x, long long y) { ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const unsigned MAXN = 1e5 + 5; unsigned n, p, l, r, phi, t, ans; unsigned pp[MAXN], fac[MAXN], ifac[MAXN], a[15][MAXN]; inline unsigned read() { unsigned x = 0; char ch = getchar(); while (!isdigit(ch)) ch = getchar(); while (isdigit(ch)) { x = x * 10 + ch - '0'...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; long long d[11], iv[N], ad[11][N], f[N]; int t, p; long long qp(long long a, int b) { long long r = 1; for (; b; b >>= 1, a = a * a % p) if (b & 1) r = r * a % p; return r; } long long c(int n, int m) { if (m < 0) return 0; long long r =...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; int n, p, l, r; int fac[MAXN]; int inv[MAXN]; int cnt[MAXN]; int power(int a, int b) { int res = 1; while (b) { if (b & 1) res *= a; a *= a; b >>= 1; } return res; } void exgcd(int a, int b, int &x, int &y) { if (!b) { x = ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> #pragma GCC optimize("O2,unroll-loops") using namespace std; const int inf = 1000000010; const long long INF = 10000000000000010LL; const int MAXN = 300010, LOG = 20; long long n, mod, k, u, v, l, r, t, p, ans; long long A[MAXN], F[MAXN], I[MAXN], phi; vector<int> prime; long long powmod(long l...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int MAXN = 100010; const int INF = 1000000007; const double PI = acos(-1.0); long long f[MAXN], g[MAXN]; long long extended_euclidean(long long a, long long b, long long &x, long long &y) { if (b == 0) { x = 1; y = 0; return ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
import java.io.*; import java.util.*; public class MainD { static StdIn in = new StdIn(); static PrintWriter out = new PrintWriter(System.out); static long p; static List<Long> pFs = new ArrayList<Long>(); static long[] fact1; static int[][] fact2; public static void main(String[] args) { int n=in.nextInt()...
JAVA
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int MN = 100010; vector<int> pr, pchk; void Sieve() { pchk = vector<int>(MN, 0); for (int i = 2; i < MN; i++) { if (!pchk[i]) { pr.push_back(i); } for (int j = 0; j < pr.size() && i * pr[j] < MN; j++) { pchk[i * pr[j]] = 1; if (i % pr...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; vector<pair<pair<int, int>, vector<int>>> lst; vector<int> fact; pair<int, vector<int>> tmp, _tmp; void init(int p) { fact.clear(); int i; for (i = 2; i * i <= p; i++) { if (p % i == 0) { fact.push_back(i); while (p % i == 0) p /= i; } else ;...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; template <class T> void _R(T &x) { cin >> x; } void _R(int &x) { scanf("%d", &x); } void _R(int64_t &x) { scanf("%lld", &x); } void _R(double &x) { scanf("%lf", &x); } void _R(char &x) { scanf(" %c", &x); } void _R(char *x) { scanf("%s", x); } void R() {} template <class ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int inf = 1.01e9; const double eps = 1e-9; int P; const int N = 1e5 + 10; int p[111], pp = 0; struct num { vector<int> a; int r; num(int x) { a = vector<int>(pp); for (int i = 0; (i) < (pp); ++i) { while (x % p[i] == 0) { a[i]++; x ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; int n, l, r; long long p; long long mod, bs, expo; pair<long long, long long> gcd(long long a, long long b) { if (a == 0) { return make_pair(0, 1); } pair<long long, long long> prev = gcd(b % a, a); return make_pair(prev.second - (b / a) * prev.first, prev.first...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; long long n, p, l1, r1, ans, cnt, q[105], r[105], Q, R, P, pw[55]; void exgcd(long long a, long long b, long long &x, long long &y) { if (b == 0) { x = 1; y = 0; return; } exgcd(b, a % b, x, y); int t = x; x = y; y = t - y * (a / b); return; } stru...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 10; long long c[N][50], pri[N], phi, fac[N], inv[N], skc, len, n; void upd(long long &x, long long y) { x = (x + y) % skc; } long long qpow(long long A, long long B) { long long C = 1; for (; B; B >>= 1, A = A * A % skc) if (B & 1) C = A * ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const long long size = 1e5 + 5; long long n, p, l, r; long long tot; long long prime[45]; long long fac[size], inv[size]; long long tim[size][45]; long long quick_pow(long long a, long long b) { long long ans = 1; while (b) { if (b & 1) ans = ans * a % p; a = a ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> #pragma GCC optimize("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } const int inf = INT_MAX / 2; const long long infl = 1LL << 60; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } re...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; long long n, p, phi, l, r, ans, g[100005][10], fac[100005], inv[100005], pr[30]; long long pw(long long a, long long b) { long long s = 1; for (; b; b /= 2, a = a * a % p) if (b & 1) s = s * a % p; return s; } long long C(long long a, long long b) { if (a < b) r...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; long long expo(long long base, long long exponent, long long mod) { long long ans = 1; while (exponent != 0) { if (exponent & 1) ans = (1LL * ans * base) % mod; base = (1LL * base * base) % mod; exponent >>= 1; } return ans % mod; } const long long N = 1...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; long long n, p, l, r; long long p0[25], pu[25], re[25]; long long mul[25][200005]; long long g[200005][25]; int cnt = 0; void make_init() { long long tempp = p; for (long long i = 2; i * i <= p; i++) { if (p % i == 0) { cnt++, p0[cnt] = i, pu[cnt] = 1; w...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool cmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; } template <typename T> inline bool cmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } int inp() { int x = 0, f = 1; char ch; for (ch = getchar(); !isdigit(ch); ch = getch...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; inline void read(int &x) { int v = 0, f = 1; char c = getchar(); while (!isdigit(c) && c != '-') c = getchar(); if (c == '-') f = -1; else v = v * 10 + c - '0'; while (isdigit(c = getchar())) v = v * 10 + c - '0'; x = v * f; } inline void read(long lon...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; int IN() { int c, f, x; while (!isdigit(c = getchar()) && c != '-') ; c == '-' ? (f = 1, x = 0) : (f = 0, x = c - '0'); while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + c - '0'; return !f ? x : -x; } const int N = 100000 + 19; int A[N], B[N], C[N]; int...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> const int N = 100010; using namespace std; long long inv[N], fac[N], p[N], t[N][20]; int n, l, r, mod, tot, Phi; inline int mult(int a, int b, int md) { long long t = 1ll * a * b; if (t >= md) t %= md; return t; } inline int power(int a, int b, int md) { int ret = 1; while (b) { i...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const long long size = 1e5 + 5; long long n, p, l, r; long long tot; long long prime[45]; long long fac[size], inv[size]; long long tim[size][45]; long long quick_pow(long long a, long long b) { long long ans = 1; while (b) { if (b & 1) ans = ans * a % p; a = a ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; class Integer { public: static void SetModulo(int mod) { mod_ = mod; phi_ = mod; divisors_.clear(); for (int i = 2; i * i <= mod; i += 1) { if (mod % i == 0) { divisors_.push_back(i); phi_ /= i; phi_ *= i - 1; while (...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const long long N = 100001; long long n, p, phi, l, r; long long ans; long long g[N][30], f[N], F[N], pr[30], t[30]; long long mi(long long a, long long b) { long long s = 1; for (; b; b >>= 1, a = (long long)a * a % p) if (b & 1) s = (long long)s * a % p; return ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; int n, l, r; long long p, phi, fac[100005], inv[100005]; int a[11], cnt[100005][11], t[100005], tot = 0; inline long long qpow(long long a, long long b, long long mod...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, p, l, r, pri[30], cnt; long long d[N][30], fac[N], inv[N]; long long POW(long long x, long long k) { long long a = 1; while (k) { if (k & 1) a = a * x % p; x = x * x % p; k >>= 1; } return a; } void init() { int s = p, re...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int P = 10, N = 1e5 + 10; int inverse(int a, int m) { if (a <= 1) return a; int ans = (1 - (long long int)inverse(m % a, a) * m) / a; if (ans < 0) ans += m; return ans; } int fact[N], ifact[N], pot[N][P]; int sz, p[P]; void primes(int n) { for (int d = 2; d ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> #pragma GCC optimize("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } const int inf = INT_MAX / 2; const long long infl = 1LL << 60; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } re...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int P = 10, N = 1e5 + 10; int inverse(int a, int m) { if (a <= 1) return a; int ans = (1 - (long long int)inverse(m % a, a) * m) / a; if (ans < 0) ans += m; return ans; } int fact[N], ifact[N], pot[N][P]; vector<int> primes(int n) { vector<int> ans; for (i...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; long long MOD = 1000000007; long double EPS = 1e-9; long long binpow(long long b, long long p, long long mod) { long long ans =...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const long long int inf = 1000000000; const long long int mod = 1000000000 + 7; inline void IO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } inline int dcmp(long double x) { return x < -1e-12 ? -1 : (x > 1e-12); } template <class T> inline int CHECK(T M...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; long long inv[100010], fac[100010], p[100010], t[100010][20]; int n, l, r, P, tot, Phi; int phi(int k) { int i, s; s = k; for (i = 2; i * i <= k; i++) { if (k % i == 0) s = s / i * (i - 1); while (k % i == 0) k /= i; } if (k > 1) s = s / k * (k - 1); ret...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; const long long int inf = 1000000000; const long long int mod = 1000000000 + 7; inline void IO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } inli...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int n, p, l, r, MOD; int fac[10][maxn], ifac[10][maxn], cnt[10][maxn], arr[maxn], mm[10]; vector<int> v; vector<int> vp; int tavan(int a, int b, int md) { int ans = 1; while (b > 0) { if (b & 1) ans = (1ll * ans * a) % md; a = (1ll * a...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; int i, j, k, n, m, p; int a[33], c[100010][33]; int fac[100010], inv[100010]; int l, r, L, R, len, Ans; inline int Pow(int x, int y) { int Ans = 1; for (; y; y >>= 1, x = 1ll * x * x % p) if (y & 1) Ans = 1ll * Ans * x % p; return Ans; } inline void Init() { int...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int P = 10, N = 1e5 + 10; inline int inverse(int a, int m) { if (a <= 1) return a; int ans = (1 - (long long int)inverse(m % a, a) * m) / a; return ans + m; } int fact[N], ifact[N], pot[N][P]; int sz, p[P]; inline void primes(int n) { for (int d = 2; d * d <= ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; long long int n, p, l, r, K; long long int gt[100005], rev[100005], gt1[100005]; long long int mu(long long int a, long long int n, long long int K) { if (n == 0) return 1; long long int q = mu(a, n / 2, K); if (n % 2 == 0) return q * q % K; return q * q % K * a % K...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 7; int n, l, r, p; int tot; long long fac[maxn], inv[maxn], a[maxn], c[maxn][30]; long long qpow(long long x, long long n) { long long res = 1; while (n) { if (n & 1) res = res * x % p; n >>= 1; x = x * x % p; } return res; } void ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using std::cerr; using std::cin; using std::max; using std::min; int n, a, b, mod, cntp, pri[100005], isp[100005], ans; std::vector<int> S; long long cal(long long x) { x -= x < mod ? 0 : mod; return x; } long long Pow(int x, int y) { int res = 1; for (; y; x = (long long)x * x % mod, y...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; long long inv[100010], fac[100010], p[100010], t[100010][20]; int n, l, r, P, tot, Phi; int phi(int k) { int i, s; s = k; for (i = 2; i * i <= k; i++) { if (k % i == 0) s = s / i * (i - 1); while (k % i == 0) k /= i; } if (k > 1) s = s / k * (k - 1); ret...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using std::cin; using std::cout; const int maxn = 100100; int n, mod, l, r; int p[100], tot; inline void exgcd(int a, int b, int& x, int& y) { if (!a) { x = 0, y = 1; return; } exgcd(b % a, a, y, x); x -= b / a * y; } inline int inv(int x) { int a, b; exgcd(x, mod, a, b); ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> const long long N = 100010; long long n, pp, l, r; long long min(long long a, long long b) { return a < b ? a : b; } long long mpow(long long a, long long b, long long p) { long long c = 1; for (; b; b >>= 1, a = 1ll * a * a % p) if (b & 1) c = 1ll * a * c % p; return c; } long long p...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> long long eucinv(long long a, long long moder) { long long b = moder, s = 1, t = 0; while (b) { long long tmp = a, q = a / b; a = b, b = tmp % a; tmp = s; s = t; t = tmp - s * q; } if (a > 1) return -1; return s < 0 ? moder + s : s; } const int N = 200010; long lon...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int MAXN = 110000; vector<int> f; long long g[MAXN], c[MAXN], d[MAXN], e[MAXN], r[MAXN]; void add(int u, int sgn, long long &cur, long long p) { for (auto q : f) { while (u % q == 0) { if (sgn > 0) g[q] *= q; else g[q] /= q; u /...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; template <class T, class U> void Min(T &a, U b) { if (a > b) a = b; } template <class T, class U> void Max(T &a, U b) { if (a < b) a = b; } long long pow(long long a, int b, int c) { long long ans = 1; while (b) { if (b & 1) ans = ans * a % c; a = 1LL * a * ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; inline void read(int &x) { int v = 0, f = 1; char c = getchar(); while (!isdigit(c) && c != '-') c = getchar(); if (c == '-') f = -1; else v = v * 10 + c - '0'; while (isdigit(c = getchar())) v = v * 10 + c - '0'; x = v * f; } inline void read(long lon...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 100100; int cnt[N][20], n, mod, jc[N], jc2[N], l, r, phi; int ksm(long long a, int b, int c = 1) { for (; b; b /= 2, a = a * a % mod) if (b & 1) c = c * a % mod; return c; } vector<int> pr; void factor(int x) { phi = x; for (int i = 2; i * i <= x; ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; long long N, P, L, R; bool V[50005]; long long Prime[50005]; long long Desc[50005], Exp[50005], cnt; pair<long long, long long> Fact[25][100005]; long long Number[100005]; void sieve() { for (long long i = 2; i <= 50000; i++) { if (V[i] == 0) { Prime[++Prime[0]]...
CPP