QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#850315 | #9768. A + B = C Problem | ciuim | Compile Error | / | / | C++14 | 1.8kb | 2025-01-10 00:40:33 | 2025-01-10 00:40:34 |
Judging History
This is the latest submission verdict.
- [2025-01-10 00:40:34]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2025-01-10 00:40:33]
- Submitted
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define len(a) int((a).size())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
std::vector<int> prefix_function(const T &str) {
int n = str.size();
std::vector<int> p(n);
for (int i = 1, j = 0; i < n; i++) {
while (j > 0 && str[i] != str[j]) {
j = p[j - 1];
}
if (str[i] == str[j]) {
j++;
}
p[i] = j;
}
return p;
}
int period(const string &s) {
int p = len(s) - prefix_function(s).back();
return len(s) % p == 0 ? p : len(s);
}
void update(string &A, string &B, int g) {
vector<int> m(g);
for (auto &x : m) {
x = rng() % 2;
}
for (int i = 0; i < len(A); i++) {
A[i] ^= m[i % g];
}
for (int i = 0; i < len(B); i++) {
B[i] ^= m[i % g];
}
}
void solve(int /* test_num */) {
ll a, b, c;
cin >> a >> b >> c;
string A(a, '0'), B(b, '0'), C(c, '0');
ll gab = gcd(a, b), gbc = gcd(b, c), gca = gcd(c, a);
if(c==a*b/gab||a==b*c/gbc||b==a*c/gac) ;
else
{
cout<<"NO\n";
return;
}
for (int it = 0; it < 40; it++) {
if (period(A) == a && period(B) == b && period(C) == c) {
cout << "Yes\n" << A << '\n' << B << '\n' << C << '\n';
return;
}
update(A, B, gab);
update(B, C, gbc);
update(C, A, gca);
}
cout << "NO\n";
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int tests;
cin >> tests;
for (int test_num = 1; test_num <= tests; test_num++) {
solve(test_num);
}
}
詳細信息
answer.code: In function ‘void solve(int)’: answer.code:50:14: error: ‘gcd’ was not declared in this scope 50 | ll gab = gcd(a, b), gbc = gcd(b, c), gca = gcd(c, a); | ^~~ answer.code:51:27: error: ‘gbc’ was not declared in this scope 51 | if(c==a*b/gab||a==b*c/gbc||b==a*c/gac) ; | ^~~ answer.code:51:39: error: ‘gac’ was not declared in this scope; did you mean ‘gab’? 51 | if(c==a*b/gab||a==b*c/gbc||b==a*c/gac) ; | ^~~ | gab answer.code:63:22: error: ‘gbc’ was not declared in this scope 63 | update(B, C, gbc); | ^~~ answer.code:64:22: error: ‘gca’ was not declared in this scope 64 | update(C, A, gca); | ^~~