QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#447804#4898. 基础图论练习题Talaodi22 3ms8500kbC++1411.5kb2024-06-18 20:06:292024-06-18 20:06:30

Judging History

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

  • [2024-06-18 20:06:30]
  • 评测
  • 测评结果:22
  • 用时:3ms
  • 内存:8500kb
  • [2024-06-18 20:06:29]
  • 提交

answer

#include <bits/stdc++.h>

namespace IO {
	template <class Stream>
	Stream& fmtbase(Stream& out, const char* format) {
		for (; *format; format++) {
			if (*format == '{' && *(format + 1) == '}') {
				throw std::invalid_argument("Error Number of Parameters!");
			}
			
			out << *format;
		}
		
		return out;
	}
	
	template <class Stream, class Fst, class... Nxt>
	Stream& fmtbase(Stream& out, const char* format, const Fst& value, const Nxt&... nxt) {
		for (; *format; format++) {
			if (*format == '{' && *(format + 1) == '}') {
				out << value;
				return fmtbase(out, format + 2, nxt...);
			} 
			
			out << *format;
		}
		
		throw std::invalid_argument("Error Number of Parameters!");
	}
	
	template <class... Ps>
	std::string to_string(const char* format, const Ps&... ps) {
		std::stringstream ss;
		fmtbase(ss, format, ps...);
		return ss.str();
	}

	template <class... Ps>
	std::ostream& fmtout(const char* format, const Ps&... ps) {
		return fmtbase(std::cout, format, ps...);
	}
	
	template <class... Ps>
	std::ostream& fmterr(const char* format, const Ps&... ps) {
		return fmtbase(std::cerr, format, ps...);
	}
	
	std::istream& allin() {
		return std::cin;
	}
	
	template <class Fst, class ... Nxt>
	std::istream& allin(Fst& fst, Nxt&... nxt) {
		std::cin >> fst;
		return allin(nxt...);
	}
	
	template <class Iter>
	std::istream& rangin(Iter begin, Iter end) {
		while (begin != end) {
			std::cin >> *begin;
			begin++;
		}
		
		return std::cin;
	}
	
	namespace Fast {
		bool sync = false;
		
		char buf[1 << 23];
		char *p1 = buf, *p2 = buf;
		
		void sync_with_ios(bool s) {
			sync = s;
		}
		
		char getchar() {
			if (sync) {
				return (char) std::cin.get();
			}
			else {
				if (p1 == p2) {
					p1 = buf;
					p2 = p1 + fread(buf, 1, 1 << 22, stdin);
				}
				
				if (p1 == p2) {
					return EOF;
				}
				else {
					char res = *p1;
					p1++;
					return res;
				}
			}
		}
		
		void read() { }
		
		template <class T, class... U>
		void read(T& x, U&... us) {
			x = 0;
			T pos = 1;
			
			char c = getchar();
			while (!isdigit(c)) {
				if (c == '-') {
					pos = -1;
				}
				
				c = getchar();
			}
			
			while (isdigit(c)) {
				x = 10 * x + c - '0';
				c = getchar();
			}
			
			x *= pos;
			read(us...);
		}
		
		template <class T>
		void write(const T& t) {
			if (t > 10) {
				write(t / 10);
			}
			
			std::cout << (int) (t % 10);
		}
	}
}

namespace Solve {
	#define int long long

	using namespace IO;

	using ll = long long;
	using ul = unsigned long long;
	using db = double;
	using ld = long double;
	using ui = unsigned;
	using ib = __int128;
	using ub = __uint128_t;

	int const INF = std::numeric_limits<int>::max();
	int const NINF = std::numeric_limits<int>::min();
	ll const LINF = std::numeric_limits<ll>::max();
	ll const LNINF = std::numeric_limits<ll>::min();
	ld const EPS = 1e-6;

	std::mt19937 mt;

	ll rnd(ll l, ll r) {
		return std::uniform_int_distribution<ll>(l, r)(mt);
	}

	template <class T>
	inline int isz(const T& v) {
		return v.size();
	}

	template <class T>
	inline T& ckmx(T& a, T b) {
		return a < b ? (a = b) : a;
	}

	template <class T>
	inline T& ckmi(T& a, T b) {
		return b < a ? (a = b) : a;
	}

	template <signed M>
	struct ModInt {
		static signed const MOD = M;

		ui v;

		ModInt() : v(0) {}

		ModInt(ll v) {
			if (-MOD <= v && v < 2 * MOD) {
				if (v >= MOD) {
					v -= MOD;
				}
			}
			else {
				v %= MOD;
			}
			if (v < 0) {
				v += MOD;
			}
			this->v = v;
		}

		ModInt operator++(signed) {
			auto t = *this;
			v = v == MOD - 1 ? 0 : v + 1;
			return t;
		}
		
		ModInt& operator++() {
			v = v == MOD - 1 ? 0 : v + 1;
			return *this;
		}
		
		ModInt operator--(signed) {
			auto t = *this;
			v = v == 0 ? MOD - 1 : v - 1;
			return t;
		}

		ModInt& operator--() {
			v = v == 0 ? MOD - 1 : v - 1;
			return *this;	
		}

		ModInt& operator+=(ModInt rhs) {
			v = v + rhs.v >= MOD ? v + rhs.v - MOD : v + rhs.v;
			return *this;
		}

		ModInt& operator-=(ModInt rhs) {
			v = v >= rhs.v ? v - rhs.v : v + MOD - rhs.v;
			return *this;
		}

		ModInt& operator*=(ModInt rhs) {
			v = (ul) v * rhs.v % MOD;
			return *this;
		}

		static void exgcd(signed a, signed b, signed& x, signed& y) {
			if (!b) {
				x = 1, y = 0;
				return;
			}

			signed t = a / b;
			exgcd(b, a - t * b, y, x);
			y -= t * x;
		}

		ModInt inv() const {
			assert(v != 0);

			signed x, y;
			exgcd(v, MOD, x, y);
			if (x < 0) {
				x += MOD;
			}			
			return x;
		}

		ModInt& operator/=(ModInt rhs) {
			return operator*=(rhs.inv());
		}

		ModInt fpow(ll b) const {
			assert(b >= 0);
			ModInt ans = 1;
			ModInt p = *this;
			while (b) {
				if (b & 1) {
					ans *= p;
				}
				p *= p;
				b >>= 1;
			}
			return ans;
		}

		friend bool operator==(ModInt a, ModInt b) {
			return a.v == b.v;
		}

		friend bool operator!=(ModInt a, ModInt b) {
			return a.v != b.v;
		}

		friend ModInt operator+(ModInt a, ModInt b) {
			return a += b;
		}

		friend ModInt operator-(ModInt a, ModInt b) {
			return a -= b;
		}

		friend ModInt operator*(ModInt a, ModInt b) {
			return a *= b;
		}

		friend ModInt operator/(ModInt a, ModInt b) {
			return a /= b;
		}

		friend ModInt operator-(ModInt a) {
			return 0 - a;
		}
	};

	template <signed MOD>
	std::istream& operator>>(std::istream& in, ModInt<MOD>& mint) {
		ll v;
		in >> v;
		mint = ModInt<MOD>(v);
		
		return in;
	}

	template <signed MOD>
	std::ostream& operator<<(std::ostream& out, ModInt<MOD> mint) {
		return out << mint.v;
	}

	template <class T, int B>
	struct FastPow {
		T baby[B + 1];
		T gaint[B + 1];
		
		FastPow(T b) {
			baby[0] = 1;
			for (int i = 1; i <= B; i++) {
				baby[i] = baby[i - 1] * b;
			}
			
			gaint[0] = 1;
			for (int i = 1; i <= B; i++) {
				gaint[i] = gaint[i - 1] * baby[B];
			}
		}
		
		T get(int n) {
			return gaint[n / B] * baby[n % B];
		}
	};

	int const MOD = 998244353;

	template <signed M>
	const signed ModInt<M>::MOD;

	using Mint = ModInt<MOD>;

	int const N = 2e5 + 10;

	struct Group {
		int d, x;
	};

	struct Edge {
		int u, v, w;
	};

	int n, a, b;
	std::vector<int> ds[N + 1];
	Group gs[N + 1];
	std::vector<Edge> eds;
	Mint ans;
	std::map<int, int> fa;

	int get(int x) {
		return fa[x] == x ? x : fa[x] = get(fa[x]);
	}

	int grt(int n, std::vector<int> d, int v) {
		while (true) {
			int mi = -1;
			for (int i = 0; i < isz(d); i++) {
				if (d[i] && (mi == -1 || d[i] < d[mi])) {
					mi = i;
				}
			}
			if (mi == -1 || n <= d[mi]) {
				return v;
			}

			int c = n / d[mi];
			for (int i = 0; i < isz(d); i++) {
				if (d[i] && i != mi) {
					ckmi(c, d[i] / d[mi]);
				}
			}

			n -= d[mi] * c;
			if (v >= n) {
				v -= ((v - n) / d[mi] + 1) * d[mi];
				if (n < d[mi] && v < 0) {
					v += d[mi];
					return v;
				}
			}

			for (int i = 0; i < isz(d); i++) {
				if (d[i] && i != mi) {
					d[i] -= c * d[mi];
				}
			}
		}
	}

	void grt_all(int n, std::vector<int> d, std::vector<int>& v) {
		std::vector<int> done(isz(v));
		while (true) {
			int mi = -1;
			for (int i = 0; i < isz(d); i++) {
				if (d[i] && (mi == -1 || d[i] < d[mi])) {
					mi = i;
				}
			}
			if (mi == -1 || n <= d[mi]) {
				return;
			}

			int c = n / d[mi];
			for (int i = 0; i < isz(d); i++) {
				if (d[i] && i != mi) {
					ckmi(c, d[i] / d[mi]);
				}
			}

			n -= d[mi] * c;
			for (int i = 0; i < isz(v); i++) {
				if (done[i]) {
					continue;
				}
				if (v[i] >= n) {
					v[i] -= ((v[i] - n) / d[mi] + 1) * d[mi];
					if (n < d[mi] && v[i] < 0) {
						v[i] += d[mi];
						done[i] = 1;
					}
				}
			}

			for (int i = 0; i < isz(d); i++) {
				if (d[i] && i != mi) {
					d[i] -= c * d[mi];
				}
			}
		}
	}

	Mint count(int n, std::vector<int> d) {
		Mint ans;
		while (true) {
			int mi = -1;
			for (int i = 0; i < isz(d); i++) {
				if (d[i] && (mi == -1 || d[i] < d[mi])) {
					mi = i;
				}
			}
			if (mi == -1 || n <= d[mi]) {
				ans += n;
				break;
			}

			int c = n / d[mi];
			for (int i = 0; i < isz(d); i++) {
				if (d[i] && i != mi) {
					ckmi(c, d[i] / d[mi]);
				}
			}

			n -= d[mi] * c;
			if (n < d[mi]) {
				ans += d[mi] - n;
			}

			for (int i = 0; i < isz(d); i++) {
				if (d[i] && i != mi) {
					d[i] -= c * d[mi];
				}
			}			
		}
		return ans;
	}

	std::vector<int> mark(int n, std::vector<int> d) {
		std::vector<int> ans, od;
		od = d;
		while (true) {
			int mi = -1;
			for (int i = 0; i < isz(d); i++) {
				if (d[i] && (mi == -1 || d[i] < d[mi])) {
					mi = i;
				}
			}
			if (mi == -1 || n <= d[mi]) {
				break;
			}

			ans.push_back(od[mi]);

			int c = n / d[mi];
			for (int i = 0; i < isz(d); i++) {
				if (d[i] && i != mi) {
					ckmi(c, d[i] / d[mi]);
				}
			}

			n -= d[mi] * c;
			for (int i = 0; i < isz(d); i++) {
				if (d[i] && i != mi) {
					d[i] -= c * d[mi];
				}
			}			
		}

		ans.erase(std::unique(ans.begin(), ans.end()), ans.end());
		return ans;
	}

	namespace Sub1 {
		void main() {
			std::sort(gs + 1, gs + a + 1, [&](const Group& a, const Group& b) {
				return a.x < b.x;
			});

			Mint lst = n;
			for (int i = 1; i <= a; i++) {
				auto d = ds[i - 1];
				d.push_back(gs[i].d);
				auto cur = count(n, d);
				ans += (lst - cur) * gs[i].x;
				ds[i] = mark(n, d);
				lst = cur;
			}
		}
	}

	namespace Sub2 {
		void solve(int l, int r, std::vector<int> vs) {
			if (l > r || isz(vs) <= 1) {
				return;
			}

			std::vector<int> ps = vs;
			int mid = (l + r) >> 1;
			grt_all(n, ds[mid], ps);
			std::map<int, std::vector<int>> mp;
			for (int i = 0; i < isz(vs); i++) {
				mp[ps[i]].push_back(vs[i]);
			}

			if (l == r) {
				for (auto& pr : mp) {
					for (int i = 0; i + 1 < isz(pr.second); i++) {
						eds.push_back({ pr.second[i], pr.second[i + 1], gs[l].x });
						ans -= gs[l].x;
					}
				}
				return;
			}

			for (auto& pr : mp) {
				solve(l, mid, pr.second);
			}

			std::vector<int> vv;
			for (auto& pr : mp) {
				vv.push_back(pr.second[0]);
			}
			solve(mid + 1, r, vv);
		}

		void main() {
			for (auto& v : eds) {
				fa[v.u] = v.u;
				fa[v.v] = v.v;
			}

			std::vector<int> vv;
			for (auto& v : eds) {
				vv.push_back(v.u);
				vv.push_back(v.v);
			}
			std::sort(vv.begin(), vv.end());
			vv.erase(std::unique(vv.begin(), vv.end()), vv.end());
			solve(1, a, vv);

			std::sort(eds.begin(), eds.end(), [&](const Edge& a, const Edge& b) {
				return a.w < b.w;
			});
			for (auto& e : eds) {
				// fmterr("? {} {} {}\n", e.u, e.v, e.w);
				if (get(e.u) != get(e.v)) {
					ans += e.w;
					fa[get(e.u)] = get(e.v);
				}
			}
		}
	}

	void main() {
		std::cin >> n >> a >> b;fmtout("{}\n", (n-1)%MOD);
return;


		for (int i = 1; i <= a; i++) {
			int d, x;
			std::cin >> d >> x;
			gs[i] = { d, x };
		}

		for (int i = 1; i <= b; i++) {
			int x, y, w;
			std::cin >> x >> y >> w;
			eds.push_back({ x, y, w });
		}

		Sub1::main();
		Sub2::main();

		fmtout("{}\n", ans);
	}

	void init() {

	}

	void clear() {

	}
}

signed main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);
	
	int t = 1;
	// std::cin >> t;

	Solve::init();
	
	for (int id = 1; id <= t; id++) {
		Solve::main();
		Solve::clear();
	}

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 8232kb

input:

161199 9 46510
147335 540442844
159493 801351455
149342 821625305
128476 843250712
95524 275754315
139315 106523502
93575 680460786
155498 328812257
146020 410466645
79992 141967 50596784
152210 68644 268349216
72549 96959 42994091
93869 27394 945120577
2909 81886 270684270
12735 35026 871917997
974...

output:

161198

result:

wrong answer 1st numbers differ - expected: '359714743', found: '161198'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 0ms
memory: 8240kb

input:

569435269457904707 2 0
490445920091092693 772271583
144842828305643603 609043885

output:

35510191

result:

wrong answer 1st numbers differ - expected: '884694794', found: '35510191'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 12
Accepted

Test #31:

score: 12
Accepted
time: 2ms
memory: 8296kb

input:

755526150476311190 942 0
492334667739348527 1
755523898623296976 1
532486636690994793 1
755526150476030559 1
755526150476249097 1
502164090270592200 1
657422656495814703 1
487200614853438190 1
311037325561173142 1
755526150475651155 1
125287404340238660 1
755524914808674090 1
755526150476177007 1
75...

output:

546044429

result:

ok 1 number(s): "546044429"

Test #32:

score: 12
Accepted
time: 0ms
memory: 8328kb

input:

507397654005748030 973 0
507391491616563534 1
486814015790119176 1
333131389050214032 1
363564475994643564 1
465930313898633808 1
139522156177690314 1
507395579080257474 1
86630001225723132 1
507395634795467574 1
507396923359845774 1
472957579895774142 1
211220548093936200 1
507397483302327114 1
507...

output:

873803086

result:

ok 1 number(s): "873803086"

Test #33:

score: 12
Accepted
time: 0ms
memory: 8312kb

input:

603106685583649335 921 0
550056634223640253 1
603106685583649293 1
603106685583647605 1
603106685583643690 1
603106685583647260 1
603106685583645101 1
603106685583206332 1
603106685583646490 1
579053271797467737 1
603106685567627560 1
392817087439609936 1
603106685583643465 1
603106685583648090 1
60...

output:

249400664

result:

ok 1 number(s): "249400664"

Test #34:

score: 12
Accepted
time: 2ms
memory: 8476kb

input:

548596182165075765 943 0
548596176080168583 1
548596182156180063 1
312480420249896937 1
548596163341594933 1
526283600729694623 1
548596158109050143 1
403131997716059924 1
434962771902913720 1
503166563025971068 1
334309818515550442 1
548596177929282553 1
548596181450546783 1
548596147814225823 1
54...

output:

315888763

result:

ok 1 number(s): "315888763"

Test #35:

score: 12
Accepted
time: 3ms
memory: 8324kb

input:

757339678164545873 914 0
639318686980737134 1
746121423482808728 1
757339678163450618 1
742690258664301578 1
615075436001700347 1
735156649863536078 1
748312116661086428 1
720777012721160772 1
733811525870561678 1
746526366212816378 1
743741354498887825 1
753440640705502328 1
735178291510182878 1
72...

output:

748030011

result:

ok 1 number(s): "748030011"

Test #36:

score: 12
Accepted
time: 2ms
memory: 8236kb

input:

678523609535069397 961 0
678523501457247993 1
678341707003179753 1
678213366219732921 1
596032992350559535 1
595323423910072641 1
178264171486256288 1
678331675351935897 1
353022445409011341 1
653752496830522075 1
662470342111950027 1
587709190707850701 1
678270056924891769 1
677027683908676175 1
67...

output:

562697340

result:

ok 1 number(s): "562697340"

Test #37:

score: 12
Accepted
time: 2ms
memory: 8260kb

input:

657959922343486841 902 0
650132742778059115 1
105135315791795180 1
438709014360864607 1
545602442587344080 1
657551739592023011 1
656791446287459707 1
657959922133303499 1
647469446648658309 1
657959922343384019 1
657959922221719769 1
336017444559583475 1
657959922253125629 1
655097797158940969 1
19...

output:

300994893

result:

ok 1 number(s): "300994893"

Test #38:

score: 12
Accepted
time: 0ms
memory: 8500kb

input:

545476271566415902 948 0
502943849064064720 1
545153141190505744 1
493528954491284005 1
487490221799012640 1
391805643829976272 1
545466964425150144 1
545474613254014704 1
545475659935859328 1
48415031136648176 1
545475230527923072 1
545472466214333424 1
545475176851931040 1
405305381846539616 1
393...

output:

621606394

result:

ok 1 number(s): "621606394"

Test #39:

score: 12
Accepted
time: 0ms
memory: 8300kb

input:

768089367882777564 903 0
768042195730743057 1
624180099065408353 1
677932298998893337 1
761912479820021969 1
373002333986242953 1
681859753068860049 1
768089367882777309 1
580672767835556559 1
768089367882750069 1
51197080622037114 1
737402458661389169 1
768089367882765501 1
707354099585711345 1
768...

output:

319523314

result:

ok 1 number(s): "319523314"

Test #40:

score: 12
Accepted
time: 0ms
memory: 8264kb

input:

803879216581914933 998 0
498552666676978841 1
803189592600095992 1
803577182309491044 1
803875534594601716 1
803827683448699636 1
803767099629307124 1
803775818980883188 1
803799950365214452 1
803816279020876020 1
803806021800931060 1
803585821604611604 1
695090981117645328 1
803690137369875484 1
68...

output:

867132754

result:

ok 1 number(s): "867132754"

Subtask #6:

score: 0
Skipped

Dependency #3:

0%

Subtask #7:

score: 0
Skipped

Dependency #3:

0%

Subtask #8:

score: 10
Accepted

Dependency #5:

100%
Accepted

Test #61:

score: 10
Accepted
time: 0ms
memory: 8292kb

input:

716429171502522215 47121 48854
684206275836370608 1
447368400898092275 1
500447584334752997 1
380938825102517800 1
703571667242752149 1
432997187680148804 1
169070786477357537 1
702163195024687605 1
706006848814479885 1
714728181809868081 1
702992487375782988 1
695502249468972696 1
29949334130159091...

output:

358321674

result:

ok 1 number(s): "358321674"

Test #62:

score: 10
Accepted
time: 2ms
memory: 8356kb

input:

760962402402047624 47788 46028
760962402400520977 1
146627560121093112 1
552500521368356496 1
609213278868935512 1
336266088659361952 1
556168263038283744 1
372691194708123248 1
542056449397110112 1
677262387740868256 1
760962402401092996 1
658355484638429264 1
760962402400992112 1
64514813498907734...

output:

397036874

result:

ok 1 number(s): "397036874"

Test #63:

score: 10
Accepted
time: 2ms
memory: 8324kb

input:

823454131189228931 47545 47996
633913455457088435 1
823454131188293887 1
823453960526785252 1
295577193570436898 1
448054862139934560 1
823454131188121371 1
662676467650910604 1
823454131188972663 1
702788755769685000 1
823453314863152631 1
823453107324243081 1
593195757060130275 1
82345390310591764...

output:

556901026

result:

ok 1 number(s): "556901026"

Test #64:

score: 10
Accepted
time: 2ms
memory: 8252kb

input:

790661905382541343 46638 46580
790661830315353694 1
628815916342495006 1
414195221334706964 1
761278128956231679 1
506248255650008574 1
504165239321589346 1
708623989919201733 1
537606289579523112 1
790661883086104374 1
790661830631248034 1
577869563291089149 1
790661889734095294 1
22748820983416533...

output:

923583785

result:

ok 1 number(s): "923583785"

Test #65:

score: 10
Accepted
time: 0ms
memory: 8232kb

input:

543995107469111870 46815 49986
543995107427386090 1
543995107385280202 1
543995107360534954 1
543995107322490794 1
543995107359865494 1
543995107430990394 1
118258633661474253 1
543995107437907018 1
543995107400709066 1
543995107388815822 1
543995107403911386 1
514372106427243364 1
54399510735645175...

output:

549708819

result:

ok 1 number(s): "549708819"

Test #66:

score: 10
Accepted
time: 2ms
memory: 8328kb

input:

973680848449912174 45809 48893
558451142980027913 1
973149521190732051 1
973151795384428051 1
730813052917184451 1
782733029576651051 1
973030580860431251 1
653086705192012191 1
885279135122797234 1
972841595364293651 1
940582507995263351 1
973068702032260451 1
762862562432814731 1
85928041435845971...

output:

760343391

result:

ok 1 number(s): "760343391"

Test #67:

score: 10
Accepted
time: 2ms
memory: 8292kb

input:

769083325181598713 45572 45512
768897660622302008 1
769083325180938609 1
768647443362725330 1
768852015940427126 1
43555486635844404 1
768689595631618217 1
769075697253837284 1
768598532992141964 1
768929558164370306 1
769077417931272476 1
768791432304759608 1
461513625257788477 1
518464733738942569...

output:

724840598

result:

ok 1 number(s): "724840598"

Test #68:

score: 10
Accepted
time: 3ms
memory: 8236kb

input:

989697766657099563 45914 49705
219852197404383689 1
491494304787067673 1
872190190190847836 1
887483404175496314 1
988437667010051631 1
988332948976172748 1
473918774016572392 1
73539620003504958 1
988923292997857377 1
142884498556990175 1
988698815467334790 1
936770813461610494 1
783682329635155073...

output:

478142716

result:

ok 1 number(s): "478142716"

Test #69:

score: 10
Accepted
time: 2ms
memory: 8476kb

input:

508086302629220899 45255 46961
508086302479732309 1
508086302451729729 1
476932514196496909 1
508086302347313329 1
479954970836181675 1
459285673375846471 1
487091876268376921 1
322586470409639114 1
472604100878658625 1
420442380335293898 1
278461218906312954 1
480604960680766945 1
28492141885045535...

output:

647915375

result:

ok 1 number(s): "647915375"

Test #70:

score: 10
Accepted
time: 0ms
memory: 8260kb

input:

608163868156115674 49705 47751
503333959958709384 1
421780903089450717 1
555039048741370741 1
532830641628222627 1
511986453645349407 1
542988393154824354 1
600140273623136626 1
412811087999765945 1
554352422959823718 1
594499283127331680 1
503907834436640092 1
608163868148396758 1
48888827368907290...

output:

64753822

result:

ok 1 number(s): "64753822"

Subtask #9:

score: 0
Skipped

Dependency #1:

0%