QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#824990#9531. Weird CeilingccsurzwWA 1ms3540kbC++231.4kb2024-12-21 16:52:352024-12-21 16:52:35

Judging History

This is the latest submission verdict.

  • [2024-12-21 16:52:35]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3540kb
  • [2024-12-21 16:52:35]
  • Submitted

answer

#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
#define N 201000
#define endl '\n'
ll mod = 998244353;
ll qpow(ll x, ll y);
int n;
vector<int> a;
string int128_to_string(__int128 x) {
    if (x == 0) return "0";
    bool is_negative = (x < 0);
    if (is_negative) x = -x;

    string result;
    while (x > 0) {
        result += '0' + x % 10;
        x /= 10;
    }

    if (is_negative) result += '-';
    reverse(result.begin(), result.end());
    return result;
}

void solve() {
    int n;
    cin >> n;
    a.clear();
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            int sum = n / i;
            a.push_back(sum);
            if (sum != i)a.push_back(i);
        }
    }
    sort(a.begin(), a.end());
    __int128 ans = 1;
    for (int i = 0; i < a.size(); i++)cout << a[i] << ' ';
    for (int i = 0; i < a.size() - 1; i++) {
        ans += (a[i + 1] - a[i])* (n / a[i]);
    }
    cout << int128_to_string(ans) << endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }

}

ll qpow(ll x, ll y) {
    ll sum = 1;
    while (y) {
        if (y & 1)sum = sum * x % mod;
        y >>= 1;
        x = x * x % mod;
    }
    return sum;
}


詳細信息

Test #1:

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

input:

3
5
451
114514

output:

1 5 21
1 11 41 451 10251
1 2 31 62 1847 3694 57257 114514 7075858

result:

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