QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#767168#9531. Weird CeilingfruianWA 53ms3576kbC++141.6kb2024-11-20 20:01:272024-11-20 20:01:31

Judging History

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

  • [2024-11-20 20:01:31]
  • 评测
  • 测评结果:WA
  • 用时:53ms
  • 内存:3576kb
  • [2024-11-20 20:01:27]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define all(x) (x).begin(), (x).end()
#define x first
#define y second
#define endl "\n" 
// #define int long long
#define sz(x) ((int)(x).size())
#define lowbit(x) ((x) & -(x))
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,x,y) for(int i = x;i<y;i++)
#define reb(i,x,y) for(int i = x;i<=y;i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
typedef long double ld;
const int N = 1e5+10, M = 2e7+10, mod = 998244353 , inf = 0x7fffffff;
const ld eps = 1e-12;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



inline void solve() {
    int n;
    cin>>n;
    int now = n;
    vector<int> res = {1, n};
    for(int i = 2;i<=sqrt(n);i++){
        if(n%i==0){
            res.push_back(i);
            if(i==n/i)continue;
            res.push_back(n/i);
        }
    }

    sort(all(res));
    int sz = res.size();



    // i64 ans = 0, lst = 1, pre = n;
    // for(int i = 0;i<res.size();i++){
    //     ans += (res[i]-lst) * pre;
    //     pre = n/res[i];
    //     lst = res[i];
    // }
    // ans += 1;


    i64 ans = 0;
    for(int i = 1;i<sz;i++){
        ans += n/res[i-1] * (res[i]-res[i-1]);
    }
    ans+=1;
    cout<<ans<<endl;

}

signed main(){
    IOS;
    cout << fixed << setprecision(10);
    int __ = 1;
    cin>>__;
    while(__--) {
        solve();
        // cout<<endl;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
5
451
114514

output:

21
10251
7075858

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 3576kb

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
315
3661
1024
439
385
625
386
4423
494
737
437
4971
394
5257
1444
551
590
969
...

result:

ok 1000 lines

Test #3:

score: -100
Wrong Answer
time: 53ms
memory: 3524kb

input:

1000
999999001
999999002
999999003
999999004
999999005
999999006
999999007
999999008
999999009
999999010
999999011
999999012
999999013
999999014
999999015
999999016
999999017
999999018
999999019
999999020
999999021
999999022
999999023
999999024
999999025
999999026
999999027
999999028
999999029
99999...

output:

969140313
2568556810
9049563687
13034762736
1030622429
15270447038
28734495627
19336490315
17111625553
15919878246
7168447203
11219033544
3532405629
7234411976
18929954323
20443802677
-1390629783
18136121654
-4299017757
28001063474
20166113141
3873602690
2821379323
24697974107
9118361949
9854620200
...

result:

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