QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#137264#187. 数树NOI_AK_ME100 ✓98ms34692kbC++2014.1kb2023-08-10 08:34:302023-08-10 08:34:33

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 08:34:33]
  • 评测
  • 测评结果:100
  • 用时:98ms
  • 内存:34692kb
  • [2023-08-10 08:34:30]
  • 提交

answer

#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>

typedef long long ll;
const ll mod = 998244353;
const ll gen = 3;
const int maxn = 2E+5 + 5;

int n, op; ll y;

namespace IObuf {
	const int LEN = 1 << 20;
	
	char ibuf[LEN + 5], *p1 = ibuf, *p2 = ibuf;
	char obuf[LEN + 5], *p3 = obuf;
	
	inline char get() {
#ifdef ONLINE_JUDGE
		return p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, LEN, stdin), p1 == p2) ? EOF : *p1++;
#endif
		return getchar();
	}
	
	inline ll getll(char c = get(), ll x = 0, ll op = 1) {
		while(c < '0' || c > '9') c == '-' && (op = -op), c = get();
		while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = get();
		return x * op;
	}
	
	inline char* flush() { fwrite(obuf, 1, p3 - obuf, stdout); return p3 = obuf; }
	inline void put(char c) {
#ifdef ONLINE_JUDGE
		p3 == obuf + LEN && flush(); *p3++ = c; return;
#endif
		putchar(c);
	}
	
	char s[20]; int t = 0;
	inline void putll(ll x, char suf = ' ') {
		if(!x) put('0');
		else {
			while(x) s[++t] = x % 10 + 48, x /= 10;
			while(t) put(s[t--]);
		} put(suf);
	}
}
using IObuf::getll;
using IObuf::putll;

inline ll fsp(ll a, ll b, ll res = 1) {
	for(a %= mod; b; a = a * a % mod, b >>= 1)
		b & 1 ? res = res * a % mod : 0; return res;
}

namespace Math {
	int L = -1; ll _Fac[maxn << 2], _Inv[maxn << 2], _inv[maxn << 2];
	
	inline void pre(int l) {
		if(L == -1) {
			_Fac[0] = _Fac[1] = 1;
			_Inv[0] = _Inv[1] = 1;
			_inv[1] = 1, L = 1;
		}
		
		for(int i = L + 1; i <= l; ++i) {
			_inv[i] = _inv[mod % i] * (mod - mod / i) % mod;
			_Fac[i] = _Fac[i - 1] * i % mod;
			_Inv[i] = _Inv[i - 1] * _inv[i] % mod;
		}
		
		L = l;
	}
	
	inline ll Fac(ll n) { if(L < n) pre(n); return _Fac[n]; }
	inline ll Inv(ll n) { if(L < n) pre(n); return _Inv[n]; }
	inline ll inv(ll n) { if(L < n) pre(n); return _inv[n]; }
};

namespace Sub0 {
	std::map<std::pair<int, int>, int> M;
	inline void main() {
		if(y == 1) return putll(1), void();

		int k = 0;
		for(int i = 1, u, v; i < n; ++i) {
			u = getll(), v = getll();
			M[std::make_pair(u, v)] = M[std::make_pair(v, u)] = 1;
		}

		for(int i = 1, u, v; i < n; ++i) {
			u = getll(), v = getll();
			k += M[std::make_pair(u, v)];
		}

		putll(fsp(y, n - k));
	}
}

namespace Sub1 {
	std::vector<int> to[maxn];

	ll K, f[maxn][2];
	inline void DFS(int u, int fa) {
		f[u][0] = 1, f[u][1] = K;
		for(int v : to[u]) if(v ^ fa) {
				DFS(v, u);

				ll f0 = (f[u][0] * f[v][0] + f[u][0] * f[v][1]) % mod;
				ll f1 = (f[u][0] * f[v][1] + f[u][1] * f[v][0] + f[u][1] * f[v][1]) % mod;
				f[u][0] = f0, f[u][1] = f1;
			}
	}

	inline void main() {
		if(y == 1) return putll(fsp(n, n - 2)), void();

		for(int i = 1, u, v; i < n; ++i) {
			u = getll(), v = getll();
			to[u].push_back(v), to[v].push_back(u);
		}

		K = fsp(1 - y, mod - 2, y * n % mod), DFS(1, 0);
		putll((f[1][1] * fsp(1 - y, n) % mod * fsp(n, mod - 3) % mod + mod) % mod);
	}
}

namespace Sub2 {
	typedef std::vector<ll> vec;
	namespace Poly {
		struct poly {
			vec f;

			// init

			inline poly(ll v = 0) : f(1) { f[0] = v; }
			inline poly(const vec &_f) : f(_f) {}
			inline poly(std::initializer_list<ll> init) : f(init) {}

			// tools

			inline ll operator[](int p) const { return f[p]; }
			inline ll &operator[](int p) { return f[p]; }

			inline int deg() const { return f.size() - 1; }
			inline void redeg(int d) { f.resize(d + 1); }

			inline poly slice(int d) const {
				if(d < f.size())
					return vec(f.begin(), f.begin() + d + 1);

				vec res(f);
				return res.resize(d + 1), res;
			}

			inline void print(int d) const {
				for(int i = 0; i <= d && i < f.size(); ++i) putll(f[i]);
				for(int i = f.size(); i <= d; ++i) putll(0);
				IObuf::put('\n');
			}

			inline ll calc(ll x) const {
				ll res = 0, tmp = 1;
				for(int i = 0; i <= deg(); ++i) {
					res = (res + f[i] * tmp) % mod;
					tmp = tmp * x % mod;
				} return res;
			}

			// operators

			inline poly operator+(const poly &P) const {
				vec res(std::max(deg(), P.deg()) + 1);

				for(int i = std::min(deg(), P.deg()); i >= 0; --i)
					(res[i] = f[i] + P[i]) >= mod ? res[i] -= mod : 0;
				for(int i = std::min(deg(), P.deg()) + 1; i < res.size(); ++i)
					res[i] = i <= deg() ? f[i] : P[i];
				return res;
			}

			inline poly operator-() const {
				poly res(f);
				for(int i = 0; i < f.size(); ++i)
					res[i] ? res[i] = mod - res[i] : 0;
				return res;
			}

			inline poly operator-(const poly &P) const { return operator+(-P); }

			inline poly operator<<(int d) const {
				poly res; res.redeg(d + deg());
				for(int i = 0; i <= deg(); ++i)
					res[i + d] = f[i];
				return res;
			}

			inline poly operator>>(int d) const {
				if(d > deg()) return poly(0);
				return vec(f.begin() + d, f.end());
			}

			inline poly operator*(const ll v) const {
				poly res(f);
				for(int i = 0; i <= deg(); ++i)
					res[i] = res[i] * v % mod;
				return res;
			}

			inline poly operator*(const poly &P) const;				// redeg to max(deg(), P.deg())
			inline poly operator/(const poly &P) const;
			inline poly operator%(const poly &P) const;

			inline poly mul(const poly &P) const;					// redeg to deg() + P.deg()

			inline poly intg(ll C) const;
			inline poly der() const;

			inline poly inv() const;
			inline poly quo(const poly &P) const;

			inline void divln(poly &res, int bit, int l, int r) const;
			inline poly ln() const;

			inline void divexp(poly &res, int bit, int l, int r) const;
			inline poly exp() const;

			inline poly pow(ll k) const;

			inline poly sqrt() const;
		};

		int Len = -1, rev[maxn * 4];
		unsigned long long rt[maxn * 4];
		inline void NTTpre(int bit) {
			if(Len >= bit) return;
			for(int i = Len + 1; i <= bit; ++i) {
				ll stp = fsp(gen, mod - 1 >> i);

				rt[1 << i] = 1;
				for(int j = (1 << i) + 1; j < (1 << i + 1); ++j)
					rt[j] = rt[j - 1] * stp % mod;
			} Len = bit;
		}

		unsigned long long tmp[maxn << 2];
		inline void NTT(poly &f, int bit, int op) {
			NTTpre(bit); int N = 1 << bit;

			if(f.deg() < N - 1) f.redeg(N - 1);
			for(int i = 0; i < N; ++i) {
				rev[i] = (rev[i >> 1] >> 1 | (i & 1) << bit - 1);
				tmp[i] = f[rev[i]] + (f[rev[i]] >> 31 & mod);			// magic
			}

			for(int len = 1; len < N; len <<= 1) {
				for(int i = 0; i < N; i += len << 1) {
					for(int k = i, x = len << 1; k < i + len; ++k, ++x) {
						ll g = tmp[k], h = tmp[k + len] * rt[x] % mod;
						tmp[k] = g + h, tmp[k + len] = mod + g - h;
					}
				}
			}

			for(int i = 0; i < N; ++i) f[i] = tmp[i] % mod;
			if(op == -1) {
				reverse(f.f.begin() + 1, f.f.begin() + N);

				ll invN = fsp(N, mod - 2);
				for(int i = 0; i < N; ++i)
					f[i] = f[i] * invN % mod;
			}
		}

		bool __WayToDeg = 0;
		inline poly poly::operator*(const poly &P) const {
			if(std::max(deg(), P.deg()) <= 128) {
				poly res; res.redeg(deg() + P.deg());
				for(int i = 0; i <= deg(); ++i)
					for(int j = 0; j <= P.deg(); ++j)
						res[i + j] += f[i] * P[j];
				for(int i = 0; i <= res.deg(); ++i) res[i] %= mod;

				if(!__WayToDeg) res.redeg(std::max(deg(), P.deg()));
				else return res;
			}

			poly F(f), G = P;

			int bit = 0, N = 1;
			while(N <= F.deg() + G.deg()) ++bit, N <<= 1;

			NTT(F, bit, 1), NTT(G, bit, 1);
			for(int i = 0; i < N; ++i)
				F[i] = F[i] * G[i] % mod;
			NTT(F, bit, -1);

			if(!__WayToDeg) return F.slice(std::max(deg(), P.deg()));
			else return F.slice(deg() + P.deg());
		}

		inline poly poly::operator/(const poly &P) const {
			if(deg() < P.deg()) return 0;

			poly g = vec(f.rbegin(), f.rend()), h = vec(P.f.rbegin(), P.f.rend());
			poly res = g.slice(deg() - P.deg()).quo(h.slice(deg() - P.deg()));
			res.redeg(deg() - P.deg()), reverse(res.f.begin(), res.f.end());

			return res;
		}

		inline poly poly::operator%(const poly &P) const {
			return operator-(operator/(P) * P).slice(P.deg() - 1);
		}

		inline poly poly::mul(const poly &P) const {
			__WayToDeg = 1; poly H = operator*(P);
			return __WayToDeg = 0, H;
		}

		inline poly poly::inv() const {
			poly g = fsp(f[0], mod - 2);
			for(int stp = 1; (1 << stp - 1) <= deg(); ++stp) {
				int N = 1 << stp;

				poly h = slice(N - 1), g0 = g;

				NTT(g, stp, 1), NTT(h, stp, 1);
				for(int i = 0; i < N; ++i)
					h[i] = h[i] * g[i] % mod;
				NTT(h, stp, -1);

				for(int i = 0; i < (N >> 1); ++i) h[i] = 0;

				NTT(h, stp, 1);
				for(int i = 0; i < N; ++i)
					g[i] = g[i] * h[i] % mod;
				NTT(g, stp, -1);

				for(int i = 0; i < (N >> 1); ++i) g[i] = 0;
				g = g0 - g;
			} return g.slice(deg());
		}

		inline poly poly::der() const {
			poly res; res.redeg(deg() - 1);
			for(int i = 1; i <= deg(); ++i)
				res[i - 1] = f[i] * i % mod;
			return res;
		}

		inline poly poly::intg(ll C = 0) const {
			poly res = C; res.redeg(deg() + 1);
			for(int i = 0; i <= deg(); ++i)
				res[i + 1] = f[i] * Math::inv(i + 1) % mod;
			return res;
		}

		inline poly poly::quo(const poly &P) const {
			if(deg() == 0) return fsp(P[0], mod - 2, f[0]);

			int bit = 0, N = 1;
			while(N <= P.deg()) ++bit, N <<= 1;

			poly g0 = P.slice((N >> 1) - 1).inv(), q0;
			poly h0 = slice((N >> 1) - 1);

			NTT(g0, bit, 1), NTT(h0, bit, 1), q0.redeg(N - 1);
			for(int i = 0; i < N; ++i)
				q0[i] = g0[i] * h0[i] % mod;
			NTT(q0, bit, -1), q0.redeg((N >> 1) - 1);

			poly q = q0, f0 = P;

			NTT(f0, bit, 1), NTT(q0, bit, 1);
			for(int i = 0; i < N; ++i)
				f0[i] = f0[i] * q0[i] % mod;
			NTT(f0, bit, -1), f0 = f0 - f;
			for(int i = 0; i < (N >> 1); ++i) f0[i] = 0;

			NTT(f0, bit, 1);
			for(int i = 0; i < N; ++i)
				f0[i] = f0[i] * g0[i] % mod;
			NTT(f0, bit, -1);

			for(int i = 0; i < (N >> 1); ++i) f0[i] = 0;
			return (q - f0).slice(deg());
		}

		const int logB = 4, B = 1 << logB;

		poly __divln_G[30][B];
		inline void poly::divln(poly &res, int bit, int l, int r) const {
			if(r - l <= 128) {
				r = std::min(r, deg() + 1);
				for(int i = l; i < r; ++i) {
					if(i == 0) res[i] = 0;
					else res[i] = (f[i] + mod - res[i] % mod * Math::inv(i) % mod) % mod;
					for(int j = i + 1; j < r; ++j)
						(res[j] += res[i] * f[j - i] % mod * i) %= mod;
				} return;
			}

			int dif = (r - l) / B, L = 0;

			poly w[B];
			while(L < B) {
				if(l + L * dif > deg()) break;
				w[L++].redeg(dif * 2 - 1);
			}

			for(int i = 0; i < L; ++i) {
				if(i != 0) {
					for(int j = 0; j < dif * 2; ++j) w[i][j] %= mod;

					Poly::NTT(w[i], bit - logB + 1, -1);
					for(int j = 0; j < dif; ++j)
						res[l + i * dif + j] += w[i][j + dif];
				}

				divln(res, bit - logB, l + i * dif, l + (i + 1) * dif);

				if(i != L - 1) {
					poly H; H.redeg(dif * 2 - 1);
					for(int j = 0; j < dif; ++j)
						H[j] = res[j + l + i * dif] * (j + l + i * dif) % mod;

					NTT(H, bit - logB + 1, 1);
					for(int j = i + 1; j < L; ++j)
						for(int k = 0; k < dif * 2; ++k)
							w[j][k] += H[k] * __divln_G[bit][j - i - 1][k];
				}
			}
		}

		inline poly poly::ln() const {
			poly res;

			int bit = 0, N = 1; while(N <= deg()) ++bit, N <<= 1;

			res.redeg(N - 1), NTTpre(bit);
			for(int b = bit; b >= logB; b -= logB) {
				int dif = 1 << (b - logB);
				for(int i = 0; i < B - 1; ++i) {
					if(dif * i > deg()) break;
					__divln_G[b][i].redeg(dif * 2 - 1);
					for(int j = 0; j < dif * 2 && i * dif + j <= deg(); ++j)
						__divln_G[b][i][j] = f[j + dif * i];
					NTT(__divln_G[b][i], b - logB + 1, 1);
				}
			}

			return divln(res, bit, 0, N), res;
		}

		poly __divexp_G[30][B];
		inline void poly::divexp(poly &res, int bit, int l, int r) const {
			if(r - l <= 128) {
				r = std::min(r, deg() + 1);
				for(int i = l; i < r; ++i) {
					if(i == 0) res[i] = 1;
					else res[i] = res[i] % mod * Math::inv(i) % mod;
					for(int j = i + 1; j < r; ++j)
						(res[j] += res[i] * f[j - i] % mod * (j - i)) %= mod;
				} return;
			}

			int mid = l + r >> 1, dif = (r - l) / B;
			int N = 1 << bit, L = 0;

			poly w[B];
			while(L < B) {
				if(l + L * dif > deg()) break;
				w[L++].redeg(dif * 2 - 1);
			}

			for(int i = 0; i < L; ++i) {
				if(i != 0) {
					for(int j = 0; j < dif * 2; ++j) w[i][j] %= mod;

					Poly::NTT(w[i], bit - logB + 1, -1);
					for(int j = 0; j < dif; ++j)
						res[l + i * dif + j] += w[i][j + dif];
				}

				divexp(res, bit - logB, l + i * dif, l + (i + 1) * dif);

				if(i != L - 1) {
					poly H; H.redeg(dif * 2 - 1);
					for(int j = 0; j < dif; ++j)
						H[j] = res[j + l + i * dif];

					NTT(H, bit - logB + 1, 1);
					for(int j = i + 1; j < L; ++j)
						for(int k = 0; k < dif * 2; ++k)
							w[j][k] += H[k] * __divexp_G[bit][j - i - 1][k];
				}
			}
		}

		inline poly poly::exp() const {
			poly res;

			int bit = 0, N = 1; while(N <= deg()) ++bit, N <<= 1;

			res.redeg(N - 1), NTTpre(bit);
			for(int b = bit; b >= logB; b -= logB) {
				int dif = 1 << (b - logB);
				for(int i = 0; i < B - 1; ++i) {
					if(dif * i > deg()) break;
					__divexp_G[b][i].redeg(dif * 2 - 1);
					for(int j = 0; j < dif * 2 && i * dif + j <= deg(); ++j)
						__divexp_G[b][i][j] = f[j + dif * i] * (j + dif * i) % mod;
					NTT(__divexp_G[b][i], b - logB + 1, 1);
				}
			}

			return divexp(res, bit, 0, N), res.slice(deg());
		}

		inline poly poly::pow(ll k) const { return (ln() * k).exp(); }
	}
	using Poly::poly;

	ll Fac[maxn], Inv[maxn];
	inline void main() {
		if(y == 1) return putll(fsp(n, 2 * (n - 2))), void();

		Fac[0] = 1;
		for(int i = 1; i <= n; ++i)
			Fac[i] = Fac[i - 1] * i % mod;
		Inv[n] = fsp(Fac[n], mod - 2);
		for(int i = n; i >= 1; --i)
			Inv[i - 1] = Inv[i] * i % mod;

		ll K = fsp(1 - y, mod - 2, y * n % mod * n % mod);

		poly F; F.redeg(n);
		for(int i = 1; i <= n; ++i)
			F[i] = fsp(i, i, K * Inv[i] % mod);
		F = F.exp();

		ll tmp = fsp(1 - y, n) * fsp(n, mod - 5) % mod;
		putll((tmp * Fac[n] % mod * F[n] % mod + mod) % mod);
	}
}

int main() {
	n = getll(), y = getll(), op = getll();
	if(op == 0) Sub0::main();
	else if(op == 1) Sub1::main();
	else Sub2::main();
	
	IObuf::flush();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 2
Accepted
time: 3ms
memory: 11104kb

input:

10 97733807 0
4 9
1 8
9 7
10 8
5 3
2 3
10 3
3 7
6 9
4 9
1 8
3 7
2 3
6 9
10 3
8 9
9 7
5 3

output:

283139561 

result:

ok 1 number(s): "283139561"

Test #2:

score: 2
Accepted
time: 98ms
memory: 24208kb

input:

97113 572544111 0
85116 86885
83696 33858
60990 57602
72077 74653
13516 84018
44398 2477
52043 7509
45435 91302
31654 55391
433 49328
81584 8482
43450 15971
67121 78887
11125 71991
93047 91000
76111 20923
78916 8417
37434 93336
78721 60237
76100 90321
59270 63662
1135 4454
65415 41283
27352 26669
48...

output:

856336316 

result:

ok 1 number(s): "856336316"

Test #3:

score: 2
Accepted
time: 95ms
memory: 23664kb

input:

92250 902613619 0
31095 16639
84385 53915
44159 81962
80893 25917
27237 84588
7606 51233
73323 55771
30127 91804
9958 62997
81440 26645
68882 1681
76746 53580
37355 54307
44191 30974
11092 4437
89270 77446
47572 43778
75558 124
67496 45257
56466 23335
46804 56128
20244 83693
40658 81391
66154 32490
...

output:

679057466 

result:

ok 1 number(s): "679057466"

Test #4:

score: 1
Accepted
time: 1ms
memory: 15172kb

input:

3 423636777 1
1 3
1 2

output:

699516852 

result:

ok 1 number(s): "699516852"

Test #5:

score: 1
Accepted
time: 3ms
memory: 13076kb

input:

5 769438012 1
4 5
3 2
2 5
1 4

output:

492436388 

result:

ok 1 number(s): "492436388"

Test #6:

score: 6
Accepted
time: 1ms
memory: 15144kb

input:

467 758878847 1
252 241
458 440
458 248
114 213
350 338
6 316
270 387
157 17
229 368
14 304
458 111
452 382
269 11
458 307
268 174
144 240
286 129
365 328
458 148
458 130
458 104
458 445
224 222
334 306
82 232
167 8
465 322
168 292
48 36
85 437
458 313
160 132
386 239
7 430
69 432
247 310
458 84
285...

output:

720629517 

result:

ok 1 number(s): "720629517"

Test #7:

score: 6
Accepted
time: 3ms
memory: 13136kb

input:

470 94671921 1
200 434
447 191
24 162
28 444
28 381
388 18
4 159
367 25
231 103
399 287
388 196
24 355
24 64
259 232
24 94
197 220
385 299
43 447
74 15
463 51
79 46
24 170
385 115
24 203
342 45
367 358
367 32
21 330
70 398
24 76
24 130
18 252
88 361
437 273
254 325
18 466
320 192
353 269
321 113
156...

output:

153298512 

result:

ok 1 number(s): "153298512"

Test #8:

score: 6
Accepted
time: 4ms
memory: 17404kb

input:

4524 955788116 1
442 892
1440 2686
1213 399
3527 623
201 3251
4141 691
1627 2975
1440 499
1440 1135
2496 3790
3569 290
1440 2964
1440 631
1440 2531
4478 4041
1840 743
4124 3981
1440 756
679 3852
1440 2464
1440 1950
1132 622
456 647
1460 1759
4448 376
1440 3624
1236 3547
2535 1927
918 3662
1313 4332
...

output:

476332561 

result:

ok 1 number(s): "476332561"

Test #9:

score: 6
Accepted
time: 1ms
memory: 17444kb

input:

4934 13052936 1
1955 3761
4683 4379
180 1094
180 1716
4374 1659
2685 1586
4371 834
180 3726
27 3326
2475 2245
180 1497
2911 1924
1128 2887
826 2223
180 1179
180 1950
2900 1865
2986 2865
3472 3041
180 2829
180 4003
180 4613
1615 378
1516 3858
1114 2652
1797 3700
4501 297
3507 696
2474 13
1128 2064
18...

output:

442772276 

result:

ok 1 number(s): "442772276"

Test #10:

score: 1
Accepted
time: 0ms
memory: 14016kb

input:

99914 1 1
13328 51343
15432 27410
93486 128
2783 37841
86248 12246
49690 70818
99645 78817
26570 57398
40214 19357
70491 18639
35104 23081
13328 95116
13687 25021
1476 58522
23862 33558
94926 49465
34578 48870
39895 53627
15197 94004
10431 63272
10559 60646
35463 2235
71010 43939
36028 59213
13328 5...

output:

545560075 

result:

ok 1 number(s): "545560075"

Test #11:

score: 5
Accepted
time: 13ms
memory: 21412kb

input:

91940 608190966 1
18216 81653
46674 52064
78462 75194
21409 7465
73047 39252
35194 76666
78462 6121
5139 60935
21747 33877
17448 5842
64278 15890
19096 57288
78462 43547
78462 14000
61106 35289
83401 53112
40004 13567
80838 50765
44158 10892
78462 28580
78462 63505
70421 85727
46643 79333
20094 4169...

output:

941195593 

result:

ok 1 number(s): "941195593"

Test #12:

score: 5
Accepted
time: 14ms
memory: 21924kb

input:

97091 216589897 1
41742 81257
38307 35015
14513 57294
86629 28982
10856 53837
18559 44404
90838 60441
38307 33369
95756 87518
77225 75848
94809 3150
38307 70495
9958 77947
38307 48125
8947 57420
38307 69865
88843 88247
7398 49661
55331 26437
45933 58433
52520 32811
96547 72130
49413 16694
53210 9268...

output:

800232100 

result:

ok 1 number(s): "800232100"

Test #13:

score: 5
Accepted
time: 12ms
memory: 19700kb

input:

94382 929228179 1
48029 8415
82505 88628
27585 68425
11764 29468
14256 15727
53750 70815
14256 2851
76929 49782
32136 78720
22557 36683
11764 89242
21195 34050
25640 84425
14256 70469
89264 35081
78910 602
14256 30438
39782 47778
63534 17760
11764 53981
11773 62043
30839 8283
93248 38771
28929 6634
...

output:

26441632 

result:

ok 1 number(s): "26441632"

Test #14:

score: 5
Accepted
time: 9ms
memory: 19864kb

input:

93859 135460247 1
89459 24319
79026 18767
89459 81036
45068 48358
70351 54764
27476 60333
34989 67544
89459 3573
83852 81185
5697 12851
89459 73501
46160 20228
4551 34751
82892 75617
67106 80741
64907 63349
26607 30363
65868 73839
6421 6743
89459 40144
22793 65615
61997 80566
54326 14858
83608 67673...

output:

682864520 

result:

ok 1 number(s): "682864520"

Test #15:

score: 1
Accepted
time: 4ms
memory: 19232kb

input:

3 393266836 2

output:

815898187 

result:

ok 1 number(s): "815898187"

Test #16:

score: 1
Accepted
time: 1ms
memory: 21324kb

input:

10 146099373 2

output:

450425451 

result:

ok 1 number(s): "450425451"

Test #17:

score: 6
Accepted
time: 3ms
memory: 21356kb

input:

464 157895536 2

output:

747558050 

result:

ok 1 number(s): "747558050"

Test #18:

score: 6
Accepted
time: 0ms
memory: 19300kb

input:

475 972594936 2

output:

462113485 

result:

ok 1 number(s): "462113485"

Test #19:

score: 6
Accepted
time: 1ms
memory: 19500kb

input:

4951 919004736 2

output:

262554311 

result:

ok 1 number(s): "262554311"

Test #20:

score: 6
Accepted
time: 0ms
memory: 19604kb

input:

4763 65325417 2

output:

576657211 

result:

ok 1 number(s): "576657211"

Test #21:

score: 1
Accepted
time: 3ms
memory: 11012kb

input:

94718 1 2

output:

643826176 

result:

ok 1 number(s): "643826176"

Test #22:

score: 5
Accepted
time: 31ms
memory: 34692kb

input:

93067 666274736 2

output:

799030046 

result:

ok 1 number(s): "799030046"

Test #23:

score: 5
Accepted
time: 30ms
memory: 29116kb

input:

91190 421191620 2

output:

151745318 

result:

ok 1 number(s): "151745318"

Test #24:

score: 5
Accepted
time: 32ms
memory: 26996kb

input:

95268 247968469 2

output:

926246865 

result:

ok 1 number(s): "926246865"

Test #25:

score: 5
Accepted
time: 26ms
memory: 24952kb

input:

93804 946644100 2

output:

804202472 

result:

ok 1 number(s): "804202472"

Extra Test:

score: 0
Extra Test Passed