QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#786440#9531. Weird CeilingxixuWA 1ms3824kbC++231.9kb2024-11-26 21:31:502024-11-26 21:31:51

Judging History

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

  • [2024-11-26 21:31:51]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3824kb
  • [2024-11-26 21:31:50]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)
#define int long long
// #define int __int128
#define re read()
#define pr(x) print(x)
#define fup(a, b, c, d) for(int a = (b); a <= (c); a += (d))
#define fdo(a, b, c, d) for(int a = (b); a >= (c); a -= (d))
typedef long long ll;
typedef pair<int , int> PII;
typedef map<int , int> MII;
const int inf = 0x3f3f3f3f, N = 5e5 + 10, M = 4e5 + 10, mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;

vector<int> v;

void divide(int x)
{
    for(int i = 2; i <= x / i; i ++ )
        if (x % i == 0)
        {
            int s = 1;
            while (x % i == 0) {
                x /= i, s *= i;
                v.push_back(s);
            }
            
        }
    if (x > 1) v.push_back(x);
}


void solve()
{
    v.clear();
    int x;
    cin >> x;
    divide(x);
    // cout << x << '\n';
    v.push_back(1);
    sort(v.begin(), v.end());

    int la;
    ll su = 0;
    vector<int> vv;
    fup(i, 0, v.size() - 1, 1) {
        fdo(j, i - 1, 0, 1) {
            if(x % (v[j] * v[i]) == 0) vv.push_back(v[j] * v[i]);
        }
    }


    // for(auto x : v) cout << x << ' ';
    // cout << '\n';

    for(auto x : vv) v.push_back(x);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin() , v.end()) , v.end());

    fup(i, 0, v.size() - 1, 1) {
        // cout << v[i] << ' ';
        if(!i) {la = v[i]; continue;}
        su += (v[i] - la) * (x / la);
        la = v[i];
    }
    // cout << '\n';
    // cout << x << ' ' << la << '\n';
    if(x != la)
    su += (x - la) * (x / la);
    else su ++;

    if(x != la) su ++;
    
    
    cout << su << '\n';
    // su += (x - )






}

signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int _ = 1;
    cin >> _;
    while(_ --)
    {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3824kb

input:

3
5
451
114514

output:

21
10251
7075858

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3560kb

input:

1000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101...

output:

1
3
7
9
21
16
43
25
37
36
111
41
157
64
71
65
273
73
343
86
113
144
507
101
201
196
163
134
813
137
931
161
221
324
295
169
1333
400
287
205
1641
218
1807
254
277
576
2163
241
589
301
443
326
2757
298
507
317
533
900
3423
345
3661
1024
439
385
625
386
4423
494
737
437
4971
394
5257
1444
551
590
969
...

result:

wrong answer 60th lines differ - expected: '315', found: '345'