QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#243792#7688. Alea Iacta Estzhoukangyang#WA 5ms4268kbC++111.6kb2023-11-08 17:23:122023-11-08 17:23:13

Judging History

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

  • [2023-11-08 17:23:13]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:4268kb
  • [2023-11-08 17:23:12]
  • 提交

answer

#include<bits/stdc++.h>
#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 ll long long
#define vi vector <int>
#define sz(a) ((int) (a).size())
#define me(f, x) memset(f, x, sizeof(f))
#define uint unsigned int
#define ull unsigned long long 
#define i128 __int128
using namespace std;
const int N = 1 << 21;
const ll mod = (ll) 998244353 * 1019260817, base = 19491001;

int n, m;

pair < vi, vi > DV(int x, int y) {
	vi ls, rs;
	L(i, 0, x - 1) 
		ls.emplace_back(i * y);
	L(i, 0, y - 1) 
		rs.emplace_back(i);
	return make_pair(ls, rs);
}

vi Mul(vi a, vi b) {
	vi c;
	for(auto&u : a) 
		for(auto&v : b)
			c.emplace_back(u + v);
	sort(c.begin(), c.end());
	return c; 
}
void Main() {
	cin >> n >> m;
	ll mul = (ll) n * m;
	ll ptl = 0, ptr = 0;
	L(i, 1, sqrt(mul)) 
		if(mul % i == 0) 
			ptl = i, ptr = mul / i;
	ll A = -1, B = -1, C = -1, D = -1;
	L(a, 1, ptl) 
		if(ptl % a == 0 && n % a == 0) {
			ll b = n / a;
			if(ptl % a == 0) {
				ll c = ptl / a;
				if(m % c == 0) {
					A = a;
					B = b;
					C = c;
					D = m / c;
				}
			}
		}
	auto p1 = DV(A, B);
	auto p2 = DV(C, D);
	auto T1 = Mul(p1.first, p2.first);
	auto T2 = Mul(p1.second, p2.second);
	cout << sz(T1) << ' ';
	for(auto&x : T1) 
		cout << x + 1 << ' ';
	cout << '\n';
	cout << sz(T2) << ' ';
	for(auto&x : T2) 
		cout << x + 1 << ' ';
	cout << '\n' << '\n';
}
int main () {
	ios :: sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t; cin >> t; while(t--) Main();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
2 8
1 9
2 9

output:

4 1 2 5 6 
4 1 2 3 4 

3 1 4 7 
3 1 2 3 

3 1 4 7 
6 1 2 2 3 3 4 


result:

ok Correct. (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 5ms
memory: 4268kb

input:

1
40013 40013

output:

40013 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...

result:

wrong answer Same as input (test case 1)