QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#245763 | #7688. Alea Iacta Est | zhoukangyang | WA | 5ms | 4120kb | C++11 | 1.9kb | 2023-11-10 11:37:02 | 2023-11-10 11:37:04 |
Judging History
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;
vi fn, fm;
L(i, 1, n) {
if(n % i == 0) {
fn.emplace_back(i);
}
}
L(i, 1, m) {
if(m % i == 0) {
fm.emplace_back(i);
}
}
i128 mn = 1e36;
int U = 1, V = 1;
for(auto u : fn) {
for(auto v : fm) {
int tu = n / u, tv = m / v;
ll ls = (ll)u * v;
ll rs = (ll)tu * tv;
if(ls <= rs) {
i128 Mul =
(i128) ls * (n + m + 2 - tu - tv) + (i128) rs * (tu + tv);
if(Mul < mn)
mn = Mul, U = u, V = v;
}
}
}
ll u = U, v = V;
ll tu = n / u, tv = m / v;
// cout << "mn = " << (ll)mn << ' ' << u << ' ' << v << endl;
vi A, B, C, D;
for(int i = 0; i < n; i += tu)
A.emplace_back(i);
for(int i = 0; i < tu; i += 1)
B.emplace_back(i);
for(int i = 0; i < m; i += tv)
C.emplace_back(i);
for(int i = 0; i < tv; i += 1)
D.emplace_back(i);
auto T1 = Mul(A, C);
auto T2 = Mul(B, D);
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3580kb
input:
3 2 8 1 9 2 9
output:
4 1 3 5 7 4 1 2 2 3 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: 4120kb
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)