前言
题目名好评。
题意
给定数 ,标记 编号为 , 编号为 , 编号为 。
输出 三个数中最大的数的编号。如存在多个最大数,输出各最大数对应编号中最小的编号。
Sol
把三个数通分为 的形式,然后比分子大小即可(模拟题意)。分子最大者即最大数;有多个最大数则按题中要求输出。
在这种做法中,注意开 __int128。
Code
Code
#include <bits/stdc++.h>
#define sfr return cerr << "safe\n", 0;
#define sf_void return cerr << "safe\n", void();
using namespace std;
using ll = long long;
using i128 = __int128;
using pr = pair<int, int>;
using prt = tuple<int, int>;
using tpt = tuple<int, int, int>;
i128 read() {
char c = getchar_unlocked();
i128 ret = 0, f = 1;
while (!isdigit(c)) { f = (c == '-' ? -1 : f), c = getchar_unlocked(); }
while (isdigit(c)) { (ret *= 10) += c - '0', c = getchar_unlocked(); }
return ret * f;
}
auto main() -> signed {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
i128 T = read();
while (T--) {
i128 a = read(), b = read(), c = read(), x = read(), y = read(), z = read();
a *= y * z, b *= x * z, c *= x * y;
auto t = max({a, b, c});
if (t == a) cout << "1\n";
else if (t == b) cout << "2\n";
else cout << "3\n";
}
}