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
917_E. Upside Down
As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tree with n ...
2
11
#include <bits/stdc++.h> long long gi() { long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) f ^= ch == '-', ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return f ? x : -x; } std::mt19937 rnd(time(NULL)); template <class T> void cxk(T& a, T b) { a = a > b ? a : b...
CPP
917_E. Upside Down
As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tree with n ...
2
11
#include <bits/stdc++.h> using namespace std; int tree[300005 * 20], lefto[300005 * 20], righto[300005 * 20], nw; struct ext { int len, link; map<char, int> next; }; ext st[300005]; int sz, last; void sa_init() { sz = last = 0; st[0].len = 0; st[0].link = -1; ++sz; } int update(int node, int st, int en, int...
CPP
917_E. Upside Down
As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tree with n ...
2
11
import java.io.*; import java.util.*; public class E { static final boolean USE_FILES = false; BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; int[][] g; boolean[] dead; int[] sz; int m; void submit() throws IOException { int n = nextInt(); m = nextInt(); int q = nextInt(); ...
JAVA
917_E. Upside Down
As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tree with n ...
2
11
#include <bits/stdc++.h> namespace _ { const int inf = 1e9 + 7; namespace _in { template <class T> inline T read() { char ch; bool flag = 0; T x = 0; while (ch = getchar(), !isdigit(ch)) if (ch == '-') flag = 1; while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); return flag ? -x : x; } struct { ...
CPP
917_E. Upside Down
As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tree with n ...
2
11
#include <bits/stdc++.h> #pragma GCC target("pclmul") using ul = std::uint32_t; using ull = std::uint64_t; using li = std::int32_t; using ll = std::int64_t; using llf = long double; using uss = std::uint8_t; const ul maxn = 1e5; const ul maxm = 1e5; const ul maxlen = 1e5; const ul maxq = 1e5; ul n, m, q; std::vector<st...
CPP
917_E. Upside Down
As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tree with n ...
2
11
#include <bits/stdc++.h> using namespace std; const int RLEN = (1 << 20) | 3; inline char gc() { static char ibuf[RLEN], *ib, *ob; (ib == ob) && (ob = (ib = ibuf) + fread(ibuf, 1, RLEN, stdin)); return (ib == ob) ? EOF : *ib++; } inline int read() { char ch = gc(); int res = 0; bool f = 1; while (!isdigit...
CPP
917_E. Upside Down
As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tree with n ...
2
11
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10, maxm = 2e5 + 10; int n, m_n, q_n, u[maxn], v[maxn], i[maxn], ans[maxn], bel[maxn], mu[maxn], mv[maxn], par[maxn], fuck_id; char par_c[maxn]; string m[maxm]; vector<pair<int, char> > g[maxn]; vector<int> has[maxn], border[maxm]; bool vis[maxn];...
CPP
917_E. Upside Down
As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tree with n ...
2
11
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> inline T1 max(T1 a, T2 b) { return a < b ? b : a; } template <typename T1, typename T2> inline T1 min(T1 a, T2 b) { return a < b ? a : b; } const char lf = '\n'; namespace ae86 { const int bufl = 1 << 15; char buf[bufl], *s = buf, *t ...
CPP
917_E. Upside Down
As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tree with n ...
2
11
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; char buf[maxn]; int n, m, q, ans[maxn]; int l[maxn], e; string s[maxn], rs[maxn]; int A1_indo[maxn], A1_indr[maxn]; int S1_indo[maxn], S1_indr[maxn]; int qu[maxn], qv[maxn], qk[maxn], qp[maxn], qs[maxn]; struct Edge { int v, c, x; } E[maxn << 1]; ...
CPP
917_E. Upside Down
As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tree with n ...
2
11
#include <bits/stdc++.h> using namespace std; int a14; inline int rd(int l, int r) { return rand() % (r - l + 1) + l; } const int mxn = 2e5 + 3; int n, m, qn, to[mxn], nxt[mxn], fir[mxn], gn = 1, co[mxn]; inline void gadd(int x, int y, char c) { to[++gn] = y, nxt[gn] = fir[x], fir[x] = gn, co[gn] = c; } int lp[mxn], ...
CPP
917_E. Upside Down
As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tree with n ...
2
11
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; int n, m, q; int pos[100005]; char ch[100005]; vector<pair<int, char> > G[100005]; int qu[100005], qv[100005], qt[100005]; int ans[100005]; int ql[100005], qr[100005]; struct SAM { int cnt, ver[100005]; int nxt[200005][26]; int par[200005], ...
CPP
917_E. Upside Down
As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tree with n ...
2
11
#include <bits/stdc++.h> long long gi() { long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) f ^= ch == '-', ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return f ? x : -x; } std::mt19937 rnd(time(NULL)); template <class T> void cxk(T& a, T b) { a = a > b ? a : b...
CPP
917_E. Upside Down
As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tree with n ...
2
11
#include <bits/stdc++.h> using namespace std; const int _ = 2e5 + 7; struct tp3 { int a, b, c; } qr[_]; string str[_][2]; int N, M, Q, ans[_], id[_][2], qrl[_][2]; struct ssam { int tr[_][26], fa[_], lst[_], cnt, nl[_][26]; int ext(int p, int c) { int t = ++cnt; lst[t] = lst[p] + 1; while (p && !tr[p]...
CPP
917_E. Upside Down
As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tree with n ...
2
11
#include <bits/stdc++.h> using namespace std; namespace IO { const int Rlen = 1 << 22 | 1; inline char gc() { static char buf[Rlen], *p1, *p2; (p1 == p2) && (p2 = (p1 = buf) + fread(buf, 1, Rlen, stdin)); return p1 == p2 ? EOF : *p1++; } int read() { int x = 0; char c = gc(); bool f = false; while (!isdig...
CPP
917_E. Upside Down
As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tree with n ...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 100050; const int M = 2 * N; const int H = 2 * M; int acgo[M][26], aclid[M], acrid[M], acnode[M], aclink[M], actid, actsz, acroot; void Insert(int &c, char *s, int lvl, int n, int id) { if (!c) c = ++actsz; if (lvl == n) { acnode[id] = c; return; ...
CPP
917_E. Upside Down
As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tree with n ...
2
11
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; int n, m, q; int pos[100005]; char ch[100005]; vector<pair<int, char> > G[100005]; int qu[100005], qv[100005], qt[100005]; int ans[100005]; int ql[100005], qr[100005]; struct SAM { int cnt, ver[100005]; int nxt[200005][26]; int par[200005], ...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long n; int k; const int maxN = 105; int a[maxN]; const int maxP = 6324554 + 100; long long x[maxP]; int y[maxP]; long long nx[maxP]; int ny[maxP]; long long cx[maxP]; int cy[maxP]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; cin ...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXL = 200 * 1000; const int MAXK = 100 + 10; long long N; int K; long long dp[MAXL][MAXK]; int a[MAXK]; long long DP(long long n, int k) { if (k == 0) return n; if (n < MAXL) { long long &p = dp[n][k]; if (p != -1) return p; return p = DP(n, k - 1...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000; long long n; int k; int a[100]; int b[100][MAXN]; inline long long get_ans(int i, long long N) { if (N == 0) return 0; if (i >= k) return N; if (N < MAXN && b[i][N] != -1) return b[i][N]; long long res = get_ans(i + 1, N) - get_ans(i + 1, N ...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; int prime[103]; int dp[103][300003]; long long dfs(long long n, int m) { if (prime[0] == 1 || n == 0) return 0; if (n < 300001 && dp[m][n] > -1) return dp[m][n]; long long ans = 0; if (m == 0) ans = n; else ans = dfs(n, m - 1) - dfs(n / prime[m - 1], m - 1...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int M = 100 + 10; const int M1 = 200000; long long int dp[101][M1 + 1]; int a[M]; long long int DFS(int pos, long long int num, int k) { if (pos == k - 1) { long long int ans = num - num / a[pos] - num / a[pos + 1] + num / a[pos] / a[pos + 1]; return...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long n; int k, i, a[111]; long long A[250001][101]; long long f(long long n, int k) { if (k == 0 || n == 0) return n; if (n <= 250000 && (~A[n][k])) return A[n][k]; long long R = f(n, k - 1) - f(n / a[k], k - 1); if (n <= 250000) A[n][k] = R; return R; } int ...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int M = 100 + 10; const int M1 = 302000; long long int dp[101][M1 + 1]; int a[M]; long long int DFS(int pos, long long int num, int k) { if (pos == k - 1) { long long int ans = num - num / a[pos] - num / a[pos + 1] + num / a[pos] / a[pos + 1]; return...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f, maxn = 105; long long n; int k, a[maxn], M = 200000, dp[maxn][200001]; long long Solve(int m, long long n) { if (m > k || n == 0) return n; if (n <= M && dp[m][n] != -1) return dp[m][n]; long long ans = Solve(m + 1, n) - Solve(m + 1, n / a[...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#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...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long n; int dp[105][100010]; int m, p[105]; long long dfs(int k, long long d) { if (d <= 100000 && dp[k][d] != -1) return dp[k][d]; if (k == 0) { if (d <= 100000) dp[k][d] = d; return d; } long long ret = d; for (int i = 1; i <= k; i++) { ret -= d...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; int prime[103]; int dp[300003][103]; long long dfs(long long n, int m) { if (prime[0] == 1 || n == 0) return 0; if (n < 300001 && dp[n][m] > -1) return dp[n][m]; long long ans = 0; if (m == 0) ans = n; else ans = dfs(n, m - 1) - dfs(n / prime[m - 1], m - 1...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
import java.io.*; import java.util.*; public class E { static long orig; static int[] list; static long[][] ret; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); orig =...
JAVA
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; template <typename T> int size(T& a) { return (int)a.size(); } template <typename T> T sqr(T a) { return a * a; } int a[100]; const int MEM = 300000; long long dm[MEM][100]; int k; long long brute(int pos, long long x) { if (pos == k) return x; if (x <= 0) return 0;...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int maxk = 100, maxv = 300001; int a[110]; long long n, mas[maxk][maxv]; int k; long long fun(int pos, long long n) { if (pos == k) return 0; if (n < maxv) { if (mas[pos][n] != -1) return mas[pos][n]; return mas[pos][n] = fun(pos + 1, n) + n...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; /** * Created by hama_du on 15/09/08. */ public class E { public static void main(String[] args) { InputReader in = new InputReader(System.in); Pri...
JAVA
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 66666; vector<int> a; long long f[N][109]; long long getans(long long n, int k) { if (n == 0 || k == 0) { return n; } if (n < N) { if (f[n][k] != -1) return f[n][k]; f[n][k] = getans(n, k - 1) - getans(n / a[k - 1], k - 1); return f[n][k]...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using ll = long long; int const nmax = 100; int v[5 + nmax]; ll dp[5 + nmax][5 + nmax * nmax]; int k; ll backt(ll number, int pos, int coef) { if (number <= nmax * nmax) return coef * dp[pos][number]; if (pos == k + 1) return number * coef; else return backt(number, pos + 1, coef)...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXM = 111; const int MAXN = 51111; long long n, dp[MAXM][MAXN]; int m, a[MAXM]; long long dfs(int dep, long long val) { if (val == 0 || dep == 0) return val; if (val < MAXN && dp[dep][val] != -1) return dp[dep][val]; long long ret = dfs(dep - 1, val) - dfs(...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long n, k; int a[124], ans; int dp[124][100024], maxN = 100024; long long get(long long nn, int ind) { if (!nn) { return 0; } if (ind == k) { return nn; } if (nn < maxN && dp[ind][nn] >= 0) { return dp[ind][nn]; } long long crr = get(nn, ind +...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const double pi = 2 * acos(0.0); long long n, uns, dp[101][50001], m; int a[101], i, k; long long run(long long ss, int k) { if (k == 0) return ss; if (ss <= m && dp[k][ss] >= 0) return dp[k][ss]; long long v = run(ss, k - 1) - run(ss / a[k], k - 1); if (ss <= m) dp...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const long long N = 102, M = 200001; long long a[N], mem[M][N]; long long dp(long long n, long long k) { if (n < M && mem[n][k] != -1) return mem[n][k]; if (k == 0) return n; if (n == 0) return 0; if (n < M) return mem[n][k] = dp(n, k - 1) - dp(n / a[k], k - 1);...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; const int N = 2e5 + 10; const long long mod = 1e9 + 7; const long long mod2 = 998244353; const long long inf = 8e18; const...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:1000000000") using namespace std; int const K = 1e2 + 13; int const N = 1e5 + 13; int const INF = 1e8 + 13; int a[K], k; long long n; int w[K][N][2]; int dp[K][N][2]; long long rec(int p, long long x, int sign) { if (x == 0LL) return 0LL; if (p == k) { re...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
import java.io.*; import java.util.*; public class E93 { static long orig; static int[] list; static long[][] ret; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); orig...
JAVA
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int maxk = 1e2 + 1, maxn = 5e5 + 1, inf = 1e9; long long n; int dp[maxn][maxk], k, q[maxn]; long long solve(long long a, int b) { if (a < maxn && dp[a][b] != -1) { return dp[a][b]; } if (a == 0) { return 0; } if (b == 0) { return a; } long lo...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long dp[100010][110]; int a[110]; long long f(long long n, int k) { if (!k) return n; if (n < 100000 && dp[n][k] != -1) return dp[n][k]; long long t = f(n, k - 1) - f(n / a[k - 1], k - 1); if (n < 100000) dp[n][k] = t; return t; } int main() { long long n; ...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; int a[100], k; long long dp[100000][100]; long long f(long long x, int i) { if (i == -1) return x; long long cnt = x; if (x < 100000 && dp[x][i] != -1) { return dp[x][i]; } for (int k = 0; k <= i && a[k] <= x; k++) cnt -= f(x / a[k], k - 1); if (x < 100000) ...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; } template <class T> void pvp(T a, T b) { for (T i = a; i != b; ++i) cout << "(" << i->first << ", " << i->second << ") "; cout << endl; } template <class T> void ...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; /** * Created by hama_du on 15/09/08. */ public class E { public static void main(String[] args) { InputReader in = new InputReader(System.in); Pri...
JAVA
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 100, M = 200000; long long n; int m; int a[N]; int f[N][M]; long long dfs(int k, long long n) { if (k >= m || n == 0) return n; if (n < M && f[k][n] != -1) return f[k][n]; long long ret = dfs(k + 1, n) - dfs(k + 1, n / a[k]); if (n < M) f[k][n] = ret; ...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const double pi = acos(-1.0); const int inf = 0x3f3f3f3f; const int N = 110; const int V = 100010; long long dp[N][V], n; int a[N], k; long long f(int i, long long n) { if (i == 0) return n - n / a[0]; if (n >= V) return f(i - 1, n) - f(i - 1, n...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int INF = 0x3fffffff; const int SINF = 0x7fffffff; const long long LINF = 0x3fffffffffffffff; const long long SLINF = 0x7fffffffffffffff; const int MAXN = 107; const int MAX = 200007; long long num; int n; int a[MAXN]; long long dp[MAXN][MAX]; void init(); void input(...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long n; int k, i, a[111]; long long A[50002][102]; long long f(long long n, int k) { if (k == 0 || n == 0) return n; if (n <= 50000 && (A[n][k] != -1)) return A[n][k]; long long R = f(n, k - 1) - f(n / a[k], k - 1); if (n <= 50000) A[n][k] = R; return R; } in...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 1e2 + 10, M = 1000 * N; long long a[N]; long long dp[N][M]; long long get_ans(long long x, long long id) { if (id < 0) return x; if (x == 1) return 1; if (x == 0) return 0; if (x < M && dp[id][x] != -1) return dp[id][x]; long long res = get_ans(x, id...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; namespace star { const int maxn = 2e5 + 10, maxm = 110; int a[maxm], k; long long n, f[maxm][maxn]; bool vis[maxm][maxn]; long long dfs(int x, long long sum) { if (x == k) return 0; if (sum < maxn and vis[x][sum]) return f[x][sum]; long long u = sum / a[x], w = u + df...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; int a[101], K, dp[101][200010]; bool cmp(int w, int v) { return w > v; } long long solve(long long N, int pos) { if (pos > K || N == 0) return N; if (N < 200010 && dp[pos][N] != -1) return dp[pos][N]; long long res = solve(N, pos + 1) - solve(N / a[pos], pos + 1); i...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#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)); } template <class T> T read_value(string s) { T result; istringstream sin(s); sin >> r...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXK = 110; const int MAXM = 110000; const int M = 1E5; int a[MAXK], f[MAXM][MAXK]; long long dp(long long n, int k) { if (k == 0) return n; if (n <= M && ~f[n][k]) return f[n][k]; long long ret = dp(n, k - 1) - dp(n / a[k], k - 1); if (n <= M) f[n][k] = r...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long n; long long r; int k; vector<int> a; const int INF = 1 << 16; long long memo[101][INF][2]; long long go(int d, long long x, int c) { if (!x) return 0; if (x < INF && memo[d][x][c & 1] != -1) return memo[d][x][c & 1]; long long res = 0; if (d == k) { r...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
//package round76; import java.io.PrintWriter; import java.util.Arrays; import java.util.BitSet; import java.util.Scanner; public class E { Scanner in; PrintWriter out; String INPUT = ""; void solve() { long n = nl(); int k = ni(); int[] a = new int[k]; for(int i = 0;i < k;i++)a[i] = ni(); Arrays.sort...
JAVA
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class ProblemE93 { private static int[] dividers; private static long[] memo; public static void main(String[] args) t...
JAVA
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int maxn = 5e4; long long n; int k, p[105]; long long f[maxn][105]; long long dfs(long long x, int y) { if (y == -1) return x; if (x < maxn) { if (f[x][y] != -1) return f[x][y]; return f[x][y] = dfs(x, y - 1) - dfs(x / p[y], y - 1); } else return dfs...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long a[105]; int k; long long n; long long X[5000000]; long long Y[5000000]; long long X1[5000000]; long long Y1[5000000]; long long X2[5000000]; long long Y2[5000000]; int main() { cin >> n >> k; for (int i = 0; i < k; i++) { cin >> a[i]; } sort(a, a + k);...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long m, mem[((long long)101 * 1000)][((long long)102)]; long long k, a[((long long)102)]; long long calc(long long n, long long x) { if (n < ((long long)101 * 1000) && mem[n][x] != -1) return mem[n][x]; if (x == -1) return n; long long res = calc(n, x - 1) - calc...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 105, M = 2e5; long long n; int k, f[N][M + 5], a[N]; long long F(int i, long long j) { if (i > k || j == 0) return j; if (j <= M && f[i][j] != -1) return f[i][j]; long long ans = F(i + 1, j) - F(i + 1, j / a[i]); if (j <= M) f[i][j] = ans; return ans...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int bound = 10000; long long f[110][bound]; int a[110]; long long solve(long long n, int k) { if (k == 0) return n; if (n < bound && f[k][n] >= 0) return f[k][n]; long long ans = solve(n, k - 1) - solve(n / a[k - 1], k - 1); if (n < bound) f[k][n] = ans; ret...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; int a[110], f[110][100010]; long long solve(int m, long long n) { if (m == 0 || n == 0) return (n); if (n <= 100000 && f[m][n] != -1) return (f[m][n]); long long ret = solve(m - 1, n) - solve(m - 1, n / a[m]); if (n <= 100000) f[m][n] = ret; return (ret); } int ma...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> const int N = 200000 + 10; const int K = 100 + 10; long long n; int k; int a[K]; long long F[K][N]; long long f(int i, long long n) { long long ans = 0; if (!i) return n; else if (n < N and ~F[i][n]) return F[i][n]; ans = f(i - 1, n) - f(i - 1, n / a[i]); if (n < N) F[i][n] = ...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long n; long long dp[300000][100]; int k; int a[2000]; long long dfs(long long n, int u) { if (u == k) return n; if (n == 0) return 0; if (n < 300000 && dp[n][u] != -1) return dp[n][u]; long long ret = dfs(n, u + 1) - dfs(n / a[u], u + 1); if (n < 300000) dp[...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long n; int k, i, a[111]; long long A[250001][101]; long long f(long long n, int k) { if (k == 0 || n == 0) return n; if (n <= 250000 && (~A[n][k])) return A[n][k]; long long R = f(n, k - 1) - f(n / a[k], k - 1); if (n <= 250000) A[n][k] = R; return R; } int ...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; struct Seg { long long n; bool plus; Seg() {} Seg(long long a, bool pos) { n = a; plus = pos; } }; long long n; int k; int a[105]; int sz[2]; Seg sg[2][5000000]; long long mul[1000000]; long long ans; const int mem = 800000; int main() { int from, to; ...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:10000000") const long double LDINF = 9128739847123.00; const long double eps = 1e-9; const int INF = 1 << 30; const long double pi = fabsl(atan2(0.0, -1.0)); using namespace std; long long n; int k; int a[1110]; void Load() { cin >> n >> k; for (int i = 0; i ...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int MAX_K = 100 + 10; const int CUT = 300000 + 10; long long memo[MAX_K][CUT], n; int a[MAX_K], k; long long rec(int at, long long n) { if (!n) return 0; if (at < 0) return n; if (n < CUT) { if (memo[at][n] != -1) return memo[at][n]; } long long ret = re...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long dp[101][50000], a[101], n, m; long long gao(long long s, int i) { if (!s || !i) return s; if (s < 50000 && ~dp[i][s]) return dp[i][s]; long long ret = gao(s, i - 1) - gao(s / a[i], i - 1); if (s < 50000) dp[i][s] = ret; return ret; } int main() { scanf...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; int i, j, k, m; int a[100010]; long long f[110][100010], n; long long dfs(int n, long long m) { if (!n) return m; if (m < 100010 && f[n][m] >= 0) return f[n][m]; long long A = dfs(n - 1, m) - dfs(n - 1, m / a[n]); if (m < 100010) f[n][m] = A; return A; } int main(...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int maxn = 100000; long long n; int k, i, j, t; int a[101]; long long dp[maxn + 1][101][2]; long long rec(long long p, int i, int t) { if (p == 0) return 0; if (i > k) return 0; if (p <= maxn) { if (dp[p][i][t] != -maxn) return dp[p][i][t]; } long long x...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long dp[101][50001]; long long a[201]; long long dfs(int n, long long k) { if (n == 1) return k / a[n]; if (k <= 50000) { if (dp[n][k] != -1) return dp[n][k]; else return dp[n][k] = k / a[n] + dfs(n - 1, k) - dfs(n - 1, k / a[n]); } return d...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 7e6; array<long long, 2> b[N], c[N]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout << setprecision(32); int k; long long n; cin >> n >> k; vector<int> a(k); for (auto &x : a) { cin >> x; } sort(a.begin(), a.end()); b[0...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long n; int k, i, a[111]; long long A[250002][102]; long long f(long long n, int k) { if (k == 0 || n == 0) return n; if (n <= 250000 && (A[n][k] != -1)) return A[n][k]; long long R = f(n, k - 1) - f(n / a[k], k - 1); if (n <= 250000) A[n][k] = R; return R; }...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long n; long long dp[100][200000]; int k; int a[2000]; long long dfs(long long n, int u) { if (u == k) return n; if (n == 0) return 0; if (n < 200000 && dp[u][n] != -1) return dp[u][n]; long long ret = dfs(n, u + 1) - dfs(n / a[u], u + 1); if (n < 200000) dp[...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long int k; long long int a[2000]; const int limite = 250000; long long int memcalcula[limite][100]; char calculado[limite][100]; long long int calcula(long long int n, int i) { if (n <= 1) return 0; if (i >= k) return 0; if (n < limite and calculado[n][i]) retur...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long dp[100][100010], a[200]; bool vst[100][100010]; long long n; int k; long long dfs(int k, long long n) { if (k == 0) return n - n / a[0]; if (k < 100 && n <= 100000) { if (vst[k][n]) return dp[k][n]; vst[k][n] = 1; return dp[k][n] = dfs(k - 1, n) - ...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; const double eps = 1e-9; int v[110], N; const int PRE = 100000; long long prec[110][PRE]; long long rek(long long n, int id) { if (n == 0) return 0; if (n < PRE && prec[id][n] != -1) return prec[id][n]; long long res; if (id) { res = -...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const long long int maxN = 1e5 + 10; long long int n, k, dp[102][100002], a[102]; long long int f(long long int m, long long int n) { if (!n) return m; if (n < 100 && m < 100000 && dp[n][m] + 1) return dp[n][m]; if (n < 100 && m < 100000) { dp[n][m] = f(m, n - 1) ...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; int a[110]; long long n; int k; const int M = 50100; long long dp[110][M]; long long r(long long num, int p) { if (num == 0) return 0; if (p >= k) return num; if ((num < M) && (dp[p][num] != -1)) return dp[p][num]; long long res = 0; res = r(num, p + 1) - r(num / ...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int maxk = 102; const int maxv = 50000; long long n; int k, a[maxk]; int dp[maxk][maxv + 2]; long long calc(int d, long long v) { if (v == 0) return 0; if (d == k) return v; if (v < maxv) { if (dp[d][v] == -1) dp[d][v] = calc(d + 1, v) - calc(d + 1, v / a[d]...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long n; long long dp[200000][100]; int k; int a[2000]; long long dfs(long long n, int u) { if (u == k) return n; if (n == 0) return 0; if (n < 200000 && dp[n][u] != -1) return dp[n][u]; long long ret = dfs(n, u + 1) - dfs(n / a[u], u + 1); if (n < 200000) dp[...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int threshold = 5000000; long long cached[threshold]; long long solve(long long n, vector<int> &a, int pointer) { if (pointer < 0 || n == 0) { return n; } const long long id = 101 * n + pointer; if (id < threshold && ~cached[id]) { return cached[id]; ...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Scanner; import java.util.StringTokenizer; /* * To change this template, choose Tools | Templates * a...
JAVA
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXK = 105, SAVE = 50000; long long N; int K, A[MAXK]; int save[MAXK][SAVE]; long long go(long long n, int num) { if (n == 0) return 0; if (num == K) return n; if (n < SAVE && save[num][n] != -1) return save[num][n]; long long answer = go(n, num + 1) - go(...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXK = 110; const int MAXM = 110000; const int M = 1E5; int a[MAXK], f[MAXM][MAXK]; long long dp(long long n, int k) { if (k == 0) return n; if (n <= M && ~f[n][k]) return f[n][k]; long long ret = dp(n, k - 1) - dp(n / a[k], k - 1); if (n <= M) f[n][k] = r...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long N, M; long long vp[120]; long long memo[101][300000]; long long dfs2(long long depth, long long rest) { if (rest == 0LL) return 0LL; if (depth == M) return rest; if (rest < 300000 && memo[depth][rest] >= 0) return memo[depth][rest]; long long res = 0LL; ...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> int dr[] = {2, 2, -2, -2, 1, -1, 1, -1}; int dc[] = {1, -1, 1, -1, 2, 2, -2, -2}; int dr1[] = {0, 0, 1, 1, 1, -1, -1, -1}; int dc1[] = {1, -1, 1, 0, -1, 0, 1, -1}; int dr2[] = {0, 0, 1, -1}; int dc2[] = {1, -1, 0, 0}; using namespace std; long long int ans, n, k; long long int a[1005], dp[102][...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; template <typename T> inline T qmin(const T a, const T b) { return a < b ? a : b; } template <typename T> inline T qmax(const T a, const T b) { return a > b ? a : b; } template <typename T> inline void getmin(T &a, const T b) { if (a > b) a = b; } template <typename T...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
import java.io.*; import java.util.*; public class Solution implements Runnable { private StringTokenizer st; private BufferedReader in; private PrintWriter out; private int[][] d; public void solve() throws IOException { long n = nextLong(); int k = nextInt(); int[] a = new int[k]; // a[0] = 2; // l...
JAVA
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> long long list[500]; long long dp[50000][100]; long long calc(long long n, int k) { if (k == 0) return n; if (n < 50000) return dp[n][k] == -1 ? dp[n][k] = calc(n, k - 1) - calc(n / list[k - 1], k - 1) : dp[n][k]; return calc(n, k - 1) - calc(n / list[k -...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long n; int k; vector<int> a; deque<long long> x, y; long long res; int main() { scanf("%I64d %d", &n, &k); a.resize(k); for (int i = 0; i < k; i++) scanf("%d", &a[i]); sort(a.rbegin(), a.rend()); x.push_back(1LL); y.push_back(n); for (int i = 0; i < k; i...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long n, k; int a[124], ans; int dp[124][10024], maxN = 10024; long long get(long long nn, int ind) { if (!nn) { return 0; } if (ind == k) { return nn; } if (nn < maxN && dp[ind][nn] >= 0) { return dp[ind][nn]; } long long crr = get(nn, ind + 1...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; namespace zyt { template <typename T> inline bool read(T &x) { char c; bool f = false; x = 0; do c = getchar(); while (c != EOF && c != '-' && !isdigit(c)); if (c == EOF) return false; if (c == '-') f = true, c = getchar(); do x = x * 10 + c - '0', c = getch...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; map<pair<long long, int>, long long> mm; long long ans[101][100000], n; int m, data[105]; bool cmp(int x, int y) { return x > y; } long long dfs(long long n, int m) { if (n == 0 || m == 0) return n; if (n >= 100000) return dfs(n, m - 1) - dfs(n / data[m], m - 1); if (...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; long long n; int k; long long a[105]; long long dp[105][100005]; long long solve(int now, long long mult) { if (now == k + 1) return mult; if (mult == 0) return 0; if (mult < 100005 && dp[now][mult] != -1) return dp[now][mult]; long long res = 0; res = solve(now +...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int LIM = 211111; const int K = 100; long long mem[K][LIM]; int k, a[K]; long long dp(int ind, long long n) { if (n == 0) return 0; if (ind == k) return n; if (n < LIM && ~mem[ind][n]) return mem[ind][n]; long long ret = dp(ind + 1, n) - dp(ind + 1, n / a[ind]...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXN = 100010; int a[101]; long long n, k, dp[101][MAXN]; long long cal(int i, long long nn) { if (i == k) return nn; if (nn >= MAXN) return cal(i + 1, nn) - cal(i + 1, nn / a[i]); if (dp[i][nn] == -1) dp[i][nn] = cal(i + 1, nn) - cal(i + 1, nn / a[i]); re...
CPP
93_E. Lostborn
Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum ...
2
11
#include <bits/stdc++.h> using namespace std; const int maxk = 101, maxn = 100000 + 10; long long n, k, a[maxk], dp[maxk][maxn]; long long f(int x, long long num) { if (num == 0) return 0; if (x == k + 1) return num; if (num < maxn && dp[x][num] != -1) return dp[x][num]; long long p = f(x + 1, num) - f(x + 1, n...
CPP