QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#601707#5272. Greatest Common Divisorship2077#WA 0ms3804kbC++231.3kb2024-09-30 11:18:462024-09-30 11:18:46

Judging History

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

  • [2024-09-30 11:18:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3804kb
  • [2024-09-30 11:18:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,m;
// cnt[255];
bool chk[10005][10005];
// vector<tuple<int,int,int>>ans;
vector<pair<int,int>>ans;
int calc(int x,int y){while (y) x/=y,swap(x,y);return x;}
int check(int x){
    for (int i=2;i*i<=x;i++)
        if (x%i==0) return 0;
    return 1;
}
void dfs(int a,int b){ 
    ans.emplace_back(a,b);int x=b-b/a;
    if (1ll*a*x+b<=n) dfs(a*x+b,a);
}
int main(){
    scanf("%d%d",&n,&m);
    for (int i=2;i<=n;i++) dfs(i,i);
    sort(ans.begin(),ans.end());
    ans.erase(unique(ans.begin(),ans.end()),ans.end());
    for (int i=1;i<=m;i++){
        long long p;scanf("%lld",&p);p--;
        if (p>=ans.size()) {puts("-1 -1");continue;}
        auto [x,y]=ans[p];
        printf("%d %d\n",x,y);
    }
    return 0;
    // n=read();
    // for (int i=2;i<=n;i++)
    //     for (int j=2;j<=i;j++){
    //         if (i==j) continue;
    //         if (calc(i,j)==__gcd(i,j))
    //             ans.emplace_back(i,j,__gcd(i,j)),
    //             chk[i][j]=1;
    //     }
    // stable_sort(ans.begin(),ans.end(),[&](tuple<int,int,int> a,tuple<int,int,int> b)
    //     {return get<2>(a)<get<2>(b);});
    // printf("%d\n",(int)ans.size());
    // for (auto [x,y,z]:ans) printf("%d %d:%d\n",x,y,z);
    return 0;
}

详细

Test #1:

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

input:

10 13
1
2
3
4
5
6
7
8
9
10
11
12
13

output:

2 2
3 3
4 2
4 4
5 5
6 6
7 7
8 8
9 3
9 9
10 4
10 10
-1 -1

result:

ok 26 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

1 1
1

output:

-1 -1

result:

ok 2 number(s): "-1 -1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

5 100
2
20
17
14
23
19
8
10
21
19
16
16
19
16
6
11
9
12
5
12
21
8
15
5
24
5
5
17
6
12
1
21
25
3
20
8
7
11
15
8
6
1
16
25
14
1
11
13
11
20
6
2
5
7
3
6
19
20
3
22
21
11
13
18
18
14
2
1
19
3
20
23
3
16
1
8
14
16
11
9
10
17
22
3
8
12
2
12
9
5
18
6
9
25
6
12
19
14
16
6

output:

3 3
-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
5 5
-1 -1
-1 -1
-1 -1
-1 -1
5 5
-1 -1
5 5
5 5
-1 -1
-1 -1
-1 -1
2 2
-1 -1
-1 -1
4 2
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
2 2
-1 -1
-1 -1
-1 -1
2 2
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
3 3
5 5
-1 -...

result:

ok 200 numbers

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3756kb

input:

20 100
289
374
235
204
189
215
84
194
242
331
216
326
264
113
181
344
124
91
39
189
256
77
228
155
201
52
386
31
384
397
267
282
226
249
400
208
48
176
131
296
288
266
75
367
298
311
388
165
11
121
44
269
325
293
392
210
365
150
221
365
188
298
23
192
223
179
245
286
103
118
314
352
394
255
78
225
4...

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
10 4
-1 -1
-...

result:

wrong answer 125th numbers differ - expected: '19', found: '20'