QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#596464#1835. Fancy FormulasWuMin4TL 0ms3632kbC++17314b2024-09-28 15:50:302024-09-28 15:50:31

Judging History

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

  • [2024-09-28 15:50:31]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3632kb
  • [2024-09-28 15:50:30]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,p,a,b,c,d,ans;
signed main() {
	cin>>p>>n;
	while(n--){
		ans=0;
		cin>>a>>b>>c>>d;
		if((a+b)%p!=(c+d)%p)
			puts("-1");
		else{
			while(a!=c&&b!=d)
				a=(a*2)%p,b=(b*2)%p,ans++;
			cout<<ans<<endl;
		}
	}
	return 0; 
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
Time Limit Exceeded

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

result: