QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#653709#1835. Fancy Formulasjiangzhihui#WA 85ms3852kbC++20968b2024-10-18 20:31:532024-10-18 20:32:04

Judging History

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

  • [2024-10-18 20:32:04]
  • 评测
  • 测评结果:WA
  • 用时:85ms
  • 内存:3852kb
  • [2024-10-18 20:31:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1919810;
typedef long long ll;
typedef pair<ll,ll> PII;
ll n,m,k,p;
ll a[N],b[N];
char s[N];
ll cnt[N];
int num[N];


void print(ll x){
    cout<<(x%p+p)%p<<" ";

}

void __(){
    ll a,b,c,d;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    if((a+b)%p!=(c+d)%p){
        puts("-1");
        return;
    }
    ll res=(a+b)%p;
    int ans=100;
    ll x=a;
    if(a==c&&b==d){
        puts("0");
        return;
    }
    for(int i=1;i<=50;i++){ 
        x*=2;
        x%=p;
        if((x-c)%res==0){
            // cout<<x-c<<" "<<res<<endl;
            ans=min(ans,i);
        }
       
    }
    x=b;
    for(int i=1;i<=50;i++){
        x*=2;
        x%=p;
        if((x-d)%res==0){
            ans=min(ans,i);
        }
        
    }
    printf("%d\n",ans);
}


int main(){
    int _=1;
    cin>>p;
    cin>>_;
    while(_--){
        __();
    }
}

詳細信息

Test #1:

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

input:

5 10
2 1 3 0
2 1 4 4
1 3 4 0
0 2 0 4
3 3 1 2
0 1 0 1
0 3 0 3
0 1 0 1
1 2 4 4
1 0 1 1

output:

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

result:

ok 10 numbers

Test #2:

score: -100
Wrong Answer
time: 85ms
memory: 3832kb

input:

97 100000
30 56 74 12
95 39 8 29
11 42 76 74
48 63 58 53
74 22 85 11
80 23 84 4
30 90 30 90
92 91 41 45
21 82 11 92
65 30 28 67
74 57 95 36
16 31 78 66
2 77 6 73
83 20 41 62
45 44 92 94
96 28 77 47
76 12 87 1
47 80 42 85
46 91 65 72
23 39 4 58
21 96 37 80
83 33 66 50
84 21 61 44
4 78 47 35
39 50 39 ...

output:

26
23
11
12
47
-1
0
18
3
24
100
3
19
2
30
29
6
7
9
24
11
25
2
40
0
13
2
39
8
24
14
1
21
7
22
100
31
-1
6
32
-1
22
30
-1
100
7
1
42
-1
1
100
100
0
-1
2
-1
2
-1
5
1
2
100
18
100
12
1
-1
100
100
11
100
100
41
-1
4
2
100
0
12
-1
100
2
-1
8
16
37
-1
100
5
4
0
-1
32
7
16
16
34
2
0
1
6
15
16
-1
-1
-1
11
5
...

result:

wrong answer 1st numbers differ - expected: '6', found: '26'