QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#716122#8340. 3 Sumicpc_zhzx034#WA 447ms18896kbC++141.8kb2024-11-06 14:25:252024-11-06 14:25:25

Judging History

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

  • [2024-11-06 14:25:25]
  • 评测
  • 测评结果:WA
  • 用时:447ms
  • 内存:18896kb
  • [2024-11-06 14:25:25]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int N = 505;
const ll mod1 = 100000000000000337;
const ll mod2 = 100000000000000423;

ll n, k, p1, q1, p2, q2, ans, a[N], b[N];

string s[N];

inline void mod(string &s) {
	if ((int)s.size() <= k) {
		return;
	}
	vector <string> vec;
	string t = "";
	for (int i = 0; i < (int)s.size(); ++i) {
		t += s[i];
		if ((int)t.size() == k) {
			vec.emplace_back(t);
			t = "";
		}
	}
	for (auto S: vec) {
		while (t.size() < S.size()) {
			t += "0";
		}
		while (S.size() < t.size()) {
			S += "0";
		}
		int j = 0;
		for (int i = 0; i < (int)S.size(); ++i) {
			int u = S[i] - '0' + t[i] - '0' + j;
			if (u >= 10) {
				u -= 10;
				j = 1;
			} else {
				j = 0;
			}
			t[i] = u + '0';
		}
		if (j) {
			t += "1";
		}
	}
	mod(t);
	s = t;
}

int main() {
	#ifdef LOCAL
		assert(freopen("test.in", "r", stdin));
		assert(freopen("test.out", "w", stdout));
	#endif
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> s[i];
		reverse(s[i].begin(), s[i].end());
		mod(s[i]);
		reverse(s[i].begin(), s[i].end());
		for (auto ch: s[i]) {
			a[i] = ((__int128)a[i] * 10 + (ch - '0')) % mod1;
			b[i] = ((__int128)b[i] * 10 + (ch - '0')) % mod2;
		}
	}
	for (int i = 1; i <= k; ++i) {
		p1 = ((__int128)p1 * 10 + 9) % mod1;
		q1 = ((__int128)q1 * 10 + 9) % mod2;
	}
	p2 = p1 * 2 % mod1;
	q2 = q1 * 2 % mod2;
	for (int i = 1; i <= n; ++i) {
		for (int j = i; j <= n; ++j) {
			for (int k = j; k <= n; ++k) {
				ll s = (a[i] + a[j] + a[k]) % mod1;
				ll t = (b[i] + b[j] + b[k]) % mod2;
				if ((s == 0 && t == 0) || (s == p1 && t == q1) || (s == p2 && t == q2)) {
					++ans;
				}
			}
		}
	}
	cout << ans << "\n";
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3616kb

input:

4 1
0
1
10
17

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 59ms
memory: 4392kb

input:

500 859
7118711592236878297922359501613604144948355616986970837340677671376753603836852811886591300370143151943368529129749813118476151865844255212534355441611481420938483178075143062691345257288242460282715389758789648541099090735875617822348551942134616963557723055980260082230902505269975518146286...

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 199ms
memory: 15552kb

input:

500 17336
11871159223687829792235950161360414494835561698697083734067767137675360383685281188659130037014315194336852912974981311847615186584425521253435544161148142093848317807514306269134525728824246028271538975878964854109909073587561782234855194213461696355772305598026008223090250526997551814628...

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: -100
Wrong Answer
time: 447ms
memory: 18896kb

input:

500 1
751324443898124078584847834484321089092662321556147445230263526014359393841194947303407593948729802551881289193716611867931891257925091769456350249725997883453296895094445731130479434019358742162771547784250401546380268386074363779242500860317042151185119666027858022664683818314351285215150806...

output:

2277515

result:

wrong answer 1st numbers differ - expected: '2327631', found: '2277515'