QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#309257#8132. Freshman's Dreamucup-team266#AC ✓36ms3640kbC++231.2kb2024-01-20 16:10:242024-01-20 16:10:24

Judging History

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

  • [2024-01-20 16:10:24]
  • 评测
  • 测评结果:AC
  • 用时:36ms
  • 内存:3640kb
  • [2024-01-20 16:10:24]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
pair<ll,ll> solve(ll n)
{
	if(!n) return mp(1,2);
	if(n%4==0)
	{
		auto pr=solve(n/2);
		pr.first*=2;
		pr.second*=2;
		return pr;
	}
	else
	{
		auto pr=solve(n/2-1);
		pr.first*=2;
		pr.second*=2;
		pr.first++;
		pr.second--;
		return pr;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		if(n%2)
			cout<<"-1\n";
		else
		{
			auto pr=solve(n);
			assert(pr.first+pr.second==((pr.first)^(n+pr.second)));
			cout<<pr.first<<" "<<pr.second<<'\n';
		}
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
2
3
6
10
18

output:

3 3
-1
7 5
13 11
25 23

result:

ok ok

Test #2:

score: 0
Accepted
time: 13ms
memory: 3608kb

input:

100000
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:

3 3
-1
6 6
-1
7 5
-1
12 12
-1
13 11
-1
14 10
-1
15 9
-1
24 24
-1
25 23
-1
26 22
-1
27 21
-1
28 20
-1
29 19
-1
30 18
-1
31 17
-1
48 48
-1
49 47
-1
50 46
-1
51 45
-1
52 44
-1
53 43
-1
54 42
-1
55 41
-1
56 40
-1
57 39
-1
58 38
-1
59 37
-1
60 36
-1
61 35
-1
62 34
-1
63 33
-1
96 96
-1
97 95
-1
98 94
-1
9...

result:

ok ok

Test #3:

score: 0
Accepted
time: 16ms
memory: 3624kb

input:

100000
76316
55087
1035148
480523
322879
607749
440658
434700
941531
657517
247448
953385
569641
592597
188131
769378
397552
94739
487375
142576
407344
532339
798526
521099
294428
414998
415977
646853
941103
21816
299379
1029240
171218
784108
711027
121363
223925
197035
899124
613355
178257
213375
3...

output:

103694 92914
-1
1041862 531002
-1
-1
-1
482473 303959
479494 306938
-1
-1
254796 138420
-1
-1
-1
-1
908977 663887
460920 325512
-1
-1
202360 190856
465816 320616
-1
923551 649313
-1
409358 377074
469643 316789
-1
-1
-1
27292 21860
-1
1038908 533956
216681 176535
916342 656522
-1
-1
-1
-1
973850 5990...

result:

ok ok

Test #4:

score: 0
Accepted
time: 24ms
memory: 3640kb

input:

100000
279938093875
699023415517
1048269983590
537007992988
908117019805
683806387338
334400705624
484515916103
888494261285
220468538805
253319179778
357268673752
644637898889
919322454545
854350801341
1022830170092
486578580191
750669735889
4206967959
937169662800
852140555915
924210466276
2534095...

output:

-1
-1
1073890805683 575376635981
543381903438 281251817394
-1
891659007557 757608434107
442078259756 382555461076
-1
-1
-1
264098543361 148218317055
453512243820 371121477012
-1
-1
-1
1061170898934 588096542730
-1
-1
-1
1018340645288 630926796376
-1
1011861047026 637406394638
264143744771 1481731156...

result:

ok ok

Test #5:

score: 0
Accepted
time: 36ms
memory: 3624kb

input:

100000
1040995214518856201
963834979320064344
718413469456747239
720594233881658007
133510227004253867
342816554559204856
24244360004792499
32003367585596768
68757795892900724
211638297745299764
478782413658379896
503496146580989968
288072253164348517
131667719615682949
186429177128265488
6043925869...

output:

-1
1058378241963455660 671004014946814804
-1
-1
-1
459638653431314172 405052475023821060
-1
34016082302280368 20027113226165584
70407694965414330 37678696091477574
249934336948505754 182411227279061862
527621582980901692 337069545474233540
539978449442206728 324712679012928504
-1
-1
2373297766399886...

result:

ok ok

Test #6:

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

input:

1
1152921504606846975

output:

-1

result:

ok ok

Extra Test:

score: 0
Extra Test Passed