QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#618784#1881. Roads of the Empireydzr00000WA 0ms3896kbC++17651b2024-10-07 10:18:072024-10-07 10:18:13

Judging History

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

  • [2024-10-07 10:18:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3896kb
  • [2024-10-07 10:18:07]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
inline void solve()
{
    long long n,u,v;
    scanf("%lld %lld %lld",&n,&u,&v);
    auto work=[&](long long u,long long v)->int
    {
        long long now=v;
        int step=0;
        while(now!=u)
        {
            if(n%now==0)
                return INT_MAX;
            now-=n%now;
            step++;
        }
        return step;
    };
    int x=work(u,v),y=work(v,u);
    if(x==INT_MAX&&y==INT_MAX)
        printf("-1\n");
    else
        printf("%d\n",min(x,y));
}
int main(){
    int t;
    scanf("%d",&t);
    while(t--)
        solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
5 1 2
8 2 5
7 7 2
6 2 5

output:

1
1
-1
2

result:

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

Test #2:

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

input:

1
88 14 2

output:

2

result:

ok 1 number(s): "2"

Test #3:

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

input:

20
3 3 3
20 3 5
3 2 2
17 10 14
4 3 3
1 1 1
5 4 3
7 1 1
11 5 10
14 9 5
2 2 2
16 15 7
3 1 3
4 3 3
1 1 1
19 9 1
18 11 2
20 12 2
8 1 5
15 4 14

output:

0
-1
0
-1
0
0
1
0
-1
-1
0
-1
-1
0
0
3
2
-1
-1
-1

result:

wrong answer 4th numbers differ - expected: '4', found: '-1'