QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#595733#5254. Differenceshzy99999#WA 1ms7884kbC++201.9kb2024-09-28 14:22:002024-09-28 14:22:03

Judging History

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

  • [2024-09-28 14:22:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7884kb
  • [2024-09-28 14:22:00]
  • 提交

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)->double {
        double d = x / mn;
        double ans = 0;
        for (int i = 1; i <= n; i++) {
            int t = a[i] * d + 0.5;
            ans += t * t;
        }
        return fabs(ans - d * d);
    };
    double now = 1e9;
    int ans = 0;
    for (int i = 1; (mx / mn - 0.5) * i <= 10000; i++) {
        double t = check(i);
        if (t < now) {
            now = t;
            ans = i;
        }
    }
    double d = ans / 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';
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7884kb

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

wrong answer 1st lines differ - expected: '1397', found: '1'