QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#239362 | #7688. Alea Iacta Est | ucup-team2303# | Compile Error | / | / | C++17 | 2.7kb | 2023-11-04 20:19:25 | 2023-11-04 20:19:28 |
Judging History
answer
/*
60 + 0 + 100 + 64 = 224.
*/
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define ll long long
#define L(i, j, k) for (int i = (j); i <= (k); i++)
#define R(i, j, k) for (int i = (j); i >= (k); i--)
#define pb push_back
#define pii pair<int, int>
inline int read()
{
int sum = 0, nega = 1;
char ch = getchar();
while (ch > '9'||ch < '0')
{
if (ch == '-') nega = -1;
ch = getchar();
}
while (ch <= '9' && ch >= '0') sum = sum * 10 + ch - '0', ch = getchar();
return sum * nega;
}
const int N = 7e7 + 9, mod = 998244353;
inline void add(int &x, int y) {x = (x + y) % mod;}
inline void del(int &x, int y) {x = (x - y + mod) % mod;}
int T, x, y, siz, a, b, ca, cb;
int G[2][N], F[109], tmp[N], id = 0;
inline void Write(int X)
{
if(X > 9) Write(X / 10);
putchar(X % 10 + '0');
}
inline void dfs(int fx, int fy, int fa, int fb, int nw)
{
if(nw == siz + 1) return ;
int fac = F[nw];
if(x % fac != 0 && y % fac != 0) {dfs(fx, fy, fa, fb, nw + 1); return ;}
if(x % fac != 0) swap(x, y), swap(fx, fy);
if(a % fac != 0) id ^= 1, swap(fa, fb), swap(a, b), swap(ca, cb);
x /= fac, a /= fac;
int val = 1, cn = 0;
L(i, 1, fac)
{
L(j, 1, ca) tmp[++cn] = G[id][j] + val - 1;
val += fx;
}
L(i, 1, cn) G[id][i] = tmp[i]; ca = cn;
fx *= fac, fa *= fac;
// puts("----------------------");
// cout << ca << " " << cb << endl;
// L(i, 1, ca) cout << G[id][i] << " "; cout << endl;
// L(i, 1, cb) cout << G[id ^ 1][i] << " "; cout << endl;
// puts("------------------------");
dfs(fx, fy, fa, fb, nw); return ;
}
inline void work()
{
ca = cb = 1;
G[0][1] = 1, G[1][1] = 1; id = 0;
dfs(1, 1, 1, 1, 1);
Write(ca); putchar(' ');
L(i, 1, ca)
{
Write(G[id][i]); putchar(' ');
}
puts("");
Write(cb); putchar(' ');
L(i, 1, cb)
{
Write(G[id ^ 1][i]); putchar(' ');
}
puts(""); return ;
}
inline void work(int x, int y, int a, int b)
{
if(x % a != 0 && x % b != 0) swap(x, y);
if(x % a != 0) swap(a, b);
printf("%lld ", a);
L(i, 1, a) printf("%lld ", i); puts("");
printf("%lld ", b);
int nw = 1;
L(i, 1, b / y)
{
L(j, 1, y) printf("%lld ", nw + j - 1);
nw += a;
}
puts(""); return ;
}
inline void solve()
{
x = read(), y = read();
ll t = 1ll * x * y, f = sqrt(t); siz = 0;
ll ff = t;
L(i, 2, f)
if(ff % i == 0)
{
F[++siz] = i;
while(ff % i == 0) ff /= i;
}
if(ff != 1)
{
if(ff == t) {puts("0"); puts("0"); return ;}
F[++siz] = ff;
}
R(i, max(1ll, f), 1)
{
if(t % i != 0) continue;
a = i, b = t / i;
if(a == x || a == y) continue;
if(a + b >= 3e6) get(x, y, a, b);
else work();
return ;
}
puts("0"); puts("0");
return ;
}
signed main()
{
T = read();
L(i, 1, T) solve();
return 0;
}
Details
answer.code: In function ‘void work(int, int, int, int)’: answer.code:80:20: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘int’ [-Wformat=] 80 | printf("%lld ", a); | ~~~^ ~ | | | | | int | long long int | %d answer.code:81:31: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘int’ [-Wformat=] 81 | L(i, 1, a) printf("%lld ", i); puts(""); | ~~~^ ~ | | | | | int | long long int | %d answer.code:82:20: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘int’ [-Wformat=] 82 | printf("%lld ", b); | ~~~^ ~ | | | | | int | long long int | %d answer.code:86:39: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘int’ [-Wformat=] 86 | L(j, 1, y) printf("%lld ", nw + j - 1); | ~~~^ ~~~~~~~~~~ | | | | | int | long long int | %d answer.code: In function ‘void solve()’: answer.code:112:37: error: no matching function for call to ‘get(int&, int&, int&, int&)’ 112 | if(a + b >= 3e6) get(x, y, a, b); | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/11/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from answer.code:5: /usr/include/c++/11/utility:223:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(std::pair<_Tp1, _Tp2>&)’ 223 | get(pair<_Tp1, _Tp2>& __in) noexcept | ^~~ /usr/include/c++/11/utility:223:5: note: template argument deduction/substitution failed: answer.code:112:37: note: mismatched types ‘std::pair<_Tp1, _Tp2>’ and ‘int’ 112 | if(a + b >= 3e6) get(x, y, a, b); | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/11/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from answer.code:5: /usr/include/c++/11/utility:228:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(std::pair<_Tp1, _Tp2>&&)’ 228 | get(pair<_Tp1, _Tp2>&& __in) noexcept | ^~~ /usr/include/c++/11/utility:228:5: note: template argument deduction/substitution failed: answer.code:112:37: note: mismatched types ‘std::pair<_Tp1, _Tp2>’ and ‘int’ 112 | if(a + b >= 3e6) get(x, y, a, b); | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/11/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from answer.code:5: /usr/include/c++/11/utility:233:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const std::pair<_Tp1, _Tp2>&)’ 233 | get(const pair<_Tp1, _Tp2>& __in) noexcept | ^~~ /usr/include/c++/11/utility:233:5: note: template argument deduction/substitution failed: answer.code:112:37: note: mismatched types ‘const std::pair<_Tp1, _Tp2>’ and ‘int’ 112 | if(a + b >= 3e6) get(x, y, a, b); | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/11/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from answer.code:5: /usr/include/c++/11/utility:238:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const std::pair<_Tp1, _Tp2>&&)’ 238 | get(const pair<_Tp1, _Tp2>&& __in) noexcept | ^~~ /usr/include/c++/11/utility:238:5: note: template argument deduction/substitution failed: answer.code:112:37: note: mismatched types ‘const std::pair<_Tp1, _Tp2>’ and ‘int’ 112 | if(a + b >= 3e6) get(x, y, a, b); | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/11/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc...