QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#595634 | #5253. Denormalization | hzy99999# | WA | 1ms | 7816kb | C++20 | 2.0kb | 2024-09-28 14:09:35 | 2024-09-28 14:09:35 |
Judging History
answer
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <bitset>
#include <stack>
#include <map>
#include <cmath>
#include <chrono>
#include <random>
#include <iomanip>
#define chmx(x, y) x=max(x,y)
#define chmn(x, y) x=min(x,y)
//#define x first
//#define y second
using namespace std;
const int N = 2e5 + 5;
const double eps = 1e-6;
const int P = 131;
const int M = 1e6 + 10;
const int mod = 123456789;
const int INF = 0x3f3f3f3f;
typedef long long ll;
typedef pair<ll, ll>PII;
int n, m, k, ans;
int st[100010];
bitset<14150>b[100010];
string s[100010];
int d[100010][4];
double a[10010];
int dis(int i, int j) {
int res = 0;
for (int k = 0; k < 4; k++) {
res += abs(d[i][k] - d[j][k]);
}
return res;
}
int dis2(string& a, string& b) {
int res = 0;
for (int i = 0; i < m; i++) {
res += (a[i] != b[i]);
}
return res;
}
int gcd(int a, int b) {
return b ? gcd(b, a % b) : a;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
double mn = 1, mx = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
chmx(mx, a[i]);
chmn(mn, a[i]);
}
auto check = [&](int x)->bool {
double d = x / mn;
//vector<int>b;
double ans = 0;
for (int i = 1; i <= n; i++) {
//b.push_back((a[i] * d));
int t = a[i] * d + 0.5;
ans += t * t;
}
return fabs(ans - d * d) < eps;
};
for (int i = 1; (mx / mn - 0.5) * i <= 10000; i++) {
if (check(i)) {
//cout << i << '\n';
double d = i / mn;
int g = 0;
for (int j = 1; j <= n; j++) {
g = gcd((int)(a[j] * d + 0.5), g);
}
for (int j = 1; j <= n; j++) {
cout << ((int)(a[j] * d + 0.5)) / g << '\n';
}
break;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 7816kb
input:
2 0.909840249060 0.414958698174
output:
result:
wrong output format Unexpected end of file - int32 expected