QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#134548#5503. Euclidean AlgorithmFeet_McYeetWA 1ms3408kbC++142.1kb2023-08-03 23:21:322023-08-03 23:22:03

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-03 23:22:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3408kb
  • [2023-08-03 23:21:32]
  • 提交

answer

#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <iterator>
#include <algorithm>
#include <bit>
#include <numeric>
using namespace std;
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#define el << '\n'
#define nl cout << '\n'
#define cina(a,n) for (int i=0; i<n; i++) cin >> a[i]
#define ll long long
#define spc << ' '
#define forn(i,n) for (int i=0; i<n; i++)
#define forl(i,s,e) for (int i=s; i<e; i++)
#define pb push_back
#define ansyes cout << "YES\n"
#define ansno cout << "NO\n"
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pss pair<short, short>
#define MAX *max_element
#define MIN *min_element
#define rsz resize
#define sz(x) ((int) x.size())
#define all(x) x.begin(), x.end()
#define bsi(x, v) (int) (lower_bound(x.begin(), x.end(), v) - x.begin());
const int inf = 1000000000;
const ll inf2 = 4000000000000000000;

ll pp(ll n) {
    if (n==0) return 0;
    ll m = sqrt(n);
    ll tot = 0;
    forl(i,1,m) {
        tot += i * (n/i-n/(i+1));
    }
    for(int i=1; i*m<=n; i++) {
        tot += n/i;
    }
    return tot;
}

int nf(ll n) {
    int tot = 1;
    for (int i=2; i*i<=n; i++) {
        int p = 0;
        while (!(n%i)) {
            n /= i;
            p++;
        }
        tot *= p+1;
    }
    if (n != 1) tot *= 2;
    // cout << n spc << tot el;
    return tot;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t; cin >> t;
    while (t--) {
        ll n; cin >> n;
        ll tot = 0;
        ll m = sqrt(n);
        forl(i,2,m) {
            tot += (ll) nf(i-1) * (n/i);
        }
        for (int i = 1; i*m<=n; i++) {
            tot += (pp(n/i-1) - pp(n/(i+1)-1))*i;
        }
        cout << tot el;
        // ll t1 = tot;
        // tot = 0;
        // forl(i,1,n) forl(j,i+1,n+1) {
        //     if (i%(j-i) == gcd(i,j)%(j-i)) tot++;
        // }
        // cout << tot el;
        // if (t1 != tot) cout << "AAAAAAAAAAA";
        // nl;
    }
}

詳細信息

Test #1:

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

input:

3
2
5
14

output:

3
9
62

result:

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