QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#94496 | #5253. Denormalization | maomao90# | WA | 3ms | 3696kb | C++17 | 2.0kb | 2023-04-06 14:14:18 | 2023-04-06 14:14:29 |
Judging History
answer
// Hallelujah, praise the one who set me free
// Hallelujah, death has lost its grip on me
// You have broken every chain, There's salvation in your name
// Jesus Christ, my living hope
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define RREP(i, s, e) for (int i = (s); i >= (e); i--)
template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define SZ(_a) (int) _a.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;
#ifndef DEBUG
#define cerr if (0) cerr
#endif
const int INF = 1000000005;
const ll LINF = 1000000000000000005ll;
const int MAXN = 10000;
int n;
ld x[MAXN];
int ans[MAXN];
int main() {
#ifndef DEBUG
ios::sync_with_stdio(0), cin.tie(0);
#endif
cin >> n;
ld mnx = INF;
REP (i, 0, n) {
cin >> x[i];
mnto(mnx, x[i]);
}
while (mnx * 10 < 1) {
mnx *= 10;
REP (i, 0, n) {
x[i] *= 10;
}
}
ld mn = INF;
int ak = -1;
REP (k, 1, MAXN * 10) {
ld error = 0;
bool pos = 1;
REP (i, 0, n) {
ld tx = x[i] * k;
int ix = round(tx);
if (ix == 0 || ix > MAXN) {
pos = 0;
break;
}
error += abs(ix - tx);
}
if (!pos) {
continue;
}
if (mnto(mn, error)) {
ak = k;
}
}
REP (i, 0, n) {
ans[i] = round(x[i] * ak);
}
int g = 0;
REP (i, 0, n) {
g = __gcd(g, ans[i]);
}
REP (i, 0, n) {
ans[i] /= g;
}
REP (i, 0, n) {
cout << ans[i] << '\n';
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 3696kb
input:
2 0.909840249060 0.414958698174
output:
296 135
result:
wrong answer incorrect solution