QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#239423#7688. Alea Iacta Estucup-team2303#WA 1ms7836kbC++174.1kb2023-11-04 20:38:172023-11-04 20:38:18

Judging History

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

  • [2023-11-04 20:38:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7836kb
  • [2023-11-04 20:38:17]
  • 提交

answer

/*
60 + 0 + 100 + 64 = 224.
*/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
#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>
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;
namespace IO {
    int len = 0;
    char ibuf[(1 << 20) + 1], *iS, *iT, out[(1 << 25) + 1];
    #define gh()                                                                   \
      (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, (1 << 20) + 1, stdin),         \
       (iS == iT ? EOF : *iS++) : *iS++)
    inline int read() {
      char ch = gh();
      int x = 0;
      char t = 0;
      while (ch < '0' || ch > '9') t |= ch == '-', ch = gh();
      while (ch >= '0' && ch <= '9') x = x * 10 + (ch ^ 48), ch = gh();
      return t ? -x : x;
    }
    inline void putc(char ch) { out[len++] = ch; }
    template <class T> inline void write(T x) {
      if (x < 0) putc('-'), x = -x;
      if (x > 9) write(x / 10);
      out[len++] = x % 10 + 48;
    }
    string getstr(void) {
      string s = "";
      char c = gh();
      while (c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == EOF) c = gh();
      while (!(c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == EOF))s.push_back(c), c = gh();
      return s;
    }
    void putstr(string str, int begin = 0, int end = -1) {
      if (end == -1)
        end = str.size();
      for (int i = begin; i < end; i++)
        putc(str[i]);
      return;
    }
    inline void flush() {
      fwrite(out, 1, len, stdout);
      len = 0;
    }
} // namespace IO by Macesuted
using IO::flush;
using IO::getstr;
using IO::putc;
using IO::putstr;
using IO::read;
using IO::write;
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); putc(' ');
	L(i, 1, ca)
	{
		write(G[id][i]); putc(' ');
	}
	putc('\n');
	write(cb); putc(' ');
	L(i, 1, cb)
	{
		write(G[id ^ 1][i]); putc(' ');
	}
	putc('\n'); return ;
}
inline void get(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);
	write(a); putchar(' ');
	L(i, 1, a)
	{
		write(i); putchar(' ');
	}
	putc('\n');
	write(b); putc(' ');
	int nw = 1;
	L(i, 1, b / y)
	{
		L(j, 1, y)
		{
			write(nw + j - 1); putc(' ');
		}
		nw += a;
	}
	putc('\n'); 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) {write(0); putc('\n'); write(0); putc('\n'); 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 ;
	}
	write(0); putc('\n'); write(0); putc('\n');
	return ;
}
signed main()
{
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);
	T = read();
	L(i, 1, T) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7836kb

input:

3
2 8
1 9
2 9

output:


result:

wrong output format Unexpected end of file - int32 expected (test case 1)