QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#883600 | #9768. A + B = C Problem | zhulexuan | Compile Error | / | / | C++14 | 3.2kb | 2025-02-05 17:13:41 | 2025-02-05 17:13:42 |
Judging History
This is the latest submission verdict.
- [2025-02-05 17:13:42]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2025-02-05 17:13:41]
- Submitted
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf INT_MAX
#define fr(i,l,r) for (i=(l); i<=(r); i++)
#define rfr(i,l,r) for (i=(l); i>=(r); i--)
template<typename T>inline void read(T &n){
T w=1; n=0; char ch=getchar();
while (!isdigit(ch) && ch!=EOF){ if (ch=='-') w=-1; ch=getchar(); }
while (isdigit(ch) && ch!=EOF){ n=(n<<3)+(n<<1)+(ch&15); ch=getchar(); }
n*=w;
}
template<typename T>inline void write(T x){
if (x==0){ putchar('0'); return ; }
T tmp;
if (x>0) tmp=x;
else tmp=-x;
if (x<0) putchar('-');
char F[105];
long long cnt=0;
while (tmp){
F[++cnt]=tmp%10+48;
tmp/=10;
}
while (cnt) putchar(F[cnt--]);
}
#define Min(x,y) x = min(x,y)
#define Max(x,y) x = max(x,y)
//基础配置=================================================================================
const ll N = 1000005;
ll n,m,k,g,p,q,r;
ll a[N], b[N], c[N];
ll gcd(ll x,ll y){
if (y==0) return x;
else return gcd(y,x%y);
}
ll lcm(ll x,ll y){ return x/gcd(x,y) * y; }
void work(){
ll i,j;
read(n), read(m), read(k);
if (n==2 && m==2 && k==2){ printf("NO\n"); return ; }
if (n==1 && m==1 && k==1){ printf("YES\n0\n0\n0\n"); return ; }
if (lcm(m,k)%n!=0 || lcm(m,n)%k!=0 || lcm(n,k)%m!=0){ printf("NO\n"); return ; }
printf("YES\n");
ll g = gcd(n,gcd(m,k)), l = lcm(n,lcm(m,k));
r = l/n, q = l/m, p = l/k;
if (p==1 && q==1 && r==1){
fr(i,1,n-2) putchar('0'); printf("01\n");
fr(i,1,n-2) putchar('0'); printf("10\n");
fr(i,1,n-2) putchar('0'); printf("11\n");
return ;
}
if ((p==1)+(q==1)+(r==1)==2){
fr(i,1,g-1) a[i] = 0; a[g] = 1;
fr(i,g+1,max(n,m,k)) a[i] = a[i-n];
fr(i,1,max(n,m,k)-1) b[i] = 0; b[max(n,m,k)] = 1;
fr(i,1,max(n,m,k)) c[i] = a[i]^b[i];
if (p==1 && q==1){
fr(i,1,g) putchar('0'+a[i]); putchar('\n');
fr(i,1,max(n,m,k)) putchar('0'+b[i]); putchar('\n');
fr(i,1,max(n,m,k)) putchar('0'+c[i]); putchar('\n');
return ;
}
if (p==1 && r==1){
fr(i,1,g) putchar('0'+a[i]); putchar('\n');
fr(i,1,max(n,m,k)) putchar('0'+c[i]); putchar('\n');
fr(i,1,max(n,m,k)) putchar('0'+b[i]); putchar('\n');
}
if (q==1 && r==1){
fr(i,1,max(n,m,k)) putchar('0'+b[i]); putchar('\n');
fr(i,1,max(n,m,k)) putchar('0'+c[i]); putchar('\n');
fr(i,1,g) putchar('0'+a[i]); putchar('\n');
}
return ;
}
fr(i,0,p-2) a[i] = 0; a[p-1] = 1;
fr(i,0,q-2) b[i] = 0; b[q-1] = 1;
fr(i,0,r-2) c[i] = 0; c[r-1] = 1;
fr(i,0,n-1){
ll x = a[(i/g)%p] ^ b[(i/g)%q];
putchar('0'+x);
} putchar('\n');
fr(i,0,m-1){
ll x = a[(i/g)%p] ^ c[(i/g)%r];
putchar('0'+x);
} putchar('\n');
fr(i,0,k-1){
ll x = b[(i/g)%q] ^ c[(i/g)%r];
putchar('0'+x);
} putchar('\n');
}
int main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
ll qt; read(qt);
while (qt--) work();
return 0;
}
//g++ a.cpp -o a -Wall -Wl,--stack=512000000 -std=c++11 -O2
詳細信息
In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from answer.code:1: /usr/include/c++/14/bits/stl_algobase.h: In instantiation of ‘constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]’: answer.code:55:9: required from here 55 | fr(i,g+1,max(n,m,k)) a[i] = a[i-n]; | ~~~^~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:306:17: error: ‘__comp’ cannot be used as a function 306 | if (__comp(__a, __b)) | ~~~~~~^~~~~~~~~~