UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#185318#2377. 二进制wosile10058ms1252kbC++706b2023-09-28 09:15:202023-09-28 12:17:35

answer

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull c[105][105];
ull M=-1;
ull find(int k,ull m){
	ull ans=0;
	int cnt=0;
	for(int i=64;i>=0;i--)if(c[i][k-cnt]<m){
		m-=c[i][k-cnt];
		cnt++;
		ans+=(1ULL<<i);
	}
	return ans;
}
int main(){
	for(int i=0;i<=70;i++){
		c[i][0]=1;
		for(int j=1;j<=i;j++)c[i][j]=c[i-1][j-1]+c[i-1][j];
	}
	int T;
	scanf("%d",&T);
	while(T--){
		ull m;
		int k;
		scanf("%llu%d",&m,&k);
		if(c[64][k-1]<m){
			printf("0 0\n");
			continue;
		}
		ull l=find(k-1,m);
		if(c[64][k-1]<m+1){
			printf("%llu %llu\n",l+1,-l-1);
			continue;
		}
		ull r=find(k-1,m+1);
		printf("%llu %llu\n",l+1,r-l);
	}
	return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 1ms
memory: 1248kb

input:

10000
1 1
1 1
2 1
1 1
1 1
1 1
6 1
4 1
1 1
5 1
3 1
1 1
3 1
1 1
1 1
3 1
5 1
4 1
1 1
4 1
5 1
1 1
3 1
3 ...

output:

1 18446744073709551615
1 18446744073709551615
0 0
1 18446744073709551615
1 18446744073709551615
1 18...

result:

ok 10000 lines

Test #2:

score: 10
Accepted
time: 0ms
memory: 1252kb

input:

10000
42 2
58 2
1 1
64 2
1 1
29 2
3 1
46 2
1 1
62 2
33 2
1 1
46 2
1 1
1 2
52 2
52 2
1 1
6 1
5 1
4 1
...

output:

2199023255553 2199023255552
144115188075855873 144115188075855872
1 18446744073709551615
92233720368...

result:

ok 10000 lines

Test #3:

score: 10
Accepted
time: 4ms
memory: 1248kb

input:

10000
1 1
5 1
11 2
1967 3
314 3
1 1
2 1
3 2
1 1
482 3
1376 3
5 1
518 3
7 2
1264 3
5 1
1 1
43 2
688 3...

output:

1 18446744073709551615
0 0
1025 1024
9223372036854784001 8192
33562625 8192
1 18446744073709551615
0...

result:

ok 10000 lines

Test #4:

score: 10
Accepted
time: 4ms
memory: 1248kb

input:

10000
6 2
67 2
4 1
3 1
10 2
1444 3
1730 3
1808 3
36 2
4 1
1489 3
18 2
1317 3
30 2
33 2
43 2
822 3
63...

output:

33 32
0 0
0 0
0 0
513 512
18014398509486081 4096
576460752303685633 262144
1152921642045800449 13743...

result:

ok 10000 lines

Test #5:

score: 10
Accepted
time: 6ms
memory: 1244kb

input:

10000
1 10
1 23
1 21
1 57
1 19
1 53
1 12
1 41
1 35
1 5
1 5
1 40
1 64
1 56
1 21
1 37
1 4
1 29
1 23
1 ...

output:

512 256
4194304 2097152
1048576 524288
72057594037927936 36028797018963968
262144 131072
45035996273...

result:

ok 10000 lines

Test #6:

score: 10
Accepted
time: 7ms
memory: 1252kb

input:

10000
3 30
1 58
8 31
3 8
7 34
1 52
4 37
5 55
1 51
1 57
3 16
10 9
5 12
7 5
9 34
3 12
6 30
8 47
1 19
9...

output:

939524096 67108864
144115188075855872 72057594037927936
2139095040 4194304
224 16
17045651456 671088...

result:

ok 10000 lines

Test #7:

score: 10
Accepted
time: 11ms
memory: 1248kb

input:

10000
1 50
9 35
1 45
5 47
8 25
9 64
7 58
1 17
7 26
3 26
10 51
5 47
1 31
5 51
1 54
9 9
1 29
7 8
5 59
...

output:

562949953421312 281474976710656
34292629504 33554432
17592186044416 8796093022208
136339441844224 21...

result:

ok 10000 lines

Test #8:

score: 10
Accepted
time: 9ms
memory: 1252kb

input:

10000
96279085620 55
21919 62
1 1
410991310 58
128257342884936 16
32 2
1926983496109 53
273781151035...

output:

18156752275605815288 4
18445618173802577408 256
1 18446744073709551615
18410697675914600240 8
929614...

result:

ok 10000 lines

Test #9:

score: 10
Accepted
time: 7ms
memory: 1248kb

input:

10000
609397314 58
83938839055331732 41
1929 3
106050747439191010 28
79727454070513347 25
2092718359...

output:

18446743916937871359 32769
8902485001267827531 2
4611686155866341377 137438953472
137152836541070556...

result:

ok 10000 lines

Test #10:

score: 10
Accepted
time: 9ms
memory: 1248kb

input:

10000
318262090679371113 39
11268952008014 52
488797365448018117 30
163471567770312245 41
1954343992...

output:

12110134414455758655 17
18385939706301365182 1
5437006568074494642 1
14807428564216957558 1
35239777...

result:

ok 10000 lines

Extra Test:

score: 0
Extra Test Passed