QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#539100#8129. Binary SequencePhantomThreshold#AC ✓112ms14384kbC++201.0kb2024-08-31 13:59:242024-08-31 13:59:24

Judging History

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

  • [2024-08-31 13:59:24]
  • 评测
  • 测评结果:AC
  • 用时:112ms
  • 内存:14384kb
  • [2024-08-31 13:59:24]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn=38;

string str[maxn+50];

void prepare(){
	str[1]="1";
	for (int i=2;i<=maxn;i++){
		int sz=str[i-1].length();
		int l=0;
		int r=0;
		for (;l<sz;l=r){
			for (;r<sz && str[i-1][r]==str[i-1][l];) r++;
			int tmp=r-l;
			vector<int> digit;
			for (;tmp;tmp/=2) digit.push_back(tmp%2);
			reverse(digit.begin(),digit.end());
			for (auto x:digit) str[i].push_back('0'+x);
			str[i].push_back(str[i-1][l]);
		}
	}
//	for (int i=1;i<=10;i++) cout << str[i] << "\n";
//	for (int i=1;i<=maxn;i++) cout << str[i].length() << "\n";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	prepare();
	
	int TC=1;
	cin >> TC;
	for (;TC--;){
		long long n,m;
		cin >> n >> m;
		if (n>=maxn){
			if (n%2==1) n=maxn-1;
			else n=maxn;
		}
		if (str[n].length()<=m){
			cout << 0 << "\n";
			continue;
		}
		else{
			int pos=(int)str[n].length()-1-m;
			cout << str[n][pos] << "\n";
		}
	}
	return 0;
}

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

详细

Test #1:

score: 100
Accepted
time: 103ms
memory: 14384kb

input:

10
4 0
4 1
4 2
4 3
4 4
4 5
4 6
6 3
6 7
118999881999119725 3

output:

1
1
0
1
1
1
0
1
1
0

result:

ok 10 numbers

Test #2:

score: 0
Accepted
time: 102ms
memory: 14380kb

input:

10
28 69772
10 7908
4 3198
4 85913
14 52729
3 20445
9 88912
17 23743
25 37356
2 97697

output:

0
0
0
0
0
0
0
0
0
0

result:

ok 10 numbers

Test #3:

score: 0
Accepted
time: 102ms
memory: 13336kb

input:

100
29 110358
18 13645
18 590344
36 550462
11 133055
8 769352
11 265432
7 158530
12 29189
2 830361
11 584395
31 693707
7 879812
19 25069
21 616926
3 85158
31 675739
17 118385
24 315535
29 59615
10 33445
17 609235
8 738138
20 209540
4 287616
32 522302
26 959741
5 453537
27 74313
28 296289
28 857972
2...

output:

0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
1
0
0
0
0
1
0
0
0
0
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0

result:

ok 100 numbers

Test #4:

score: 0
Accepted
time: 112ms
memory: 13656kb

input:

100000
702433635413308636 962533
864089450531108488 538792
262747333715821506 454514
859830947243984718 105219
365621373252206174 447331
890829905503831899 507146
116987306031929573 154370
157986473366693144 364746
502917586764426513 49981
874588963478161584 594867
467219058104100510 790503
11034861...

output:

1
1
1
1
1
1
1
0
1
0
1
0
1
1
1
1
0
1
1
1
1
1
0
1
0
0
0
0
1
1
1
0
0
1
1
0
0
1
0
1
1
1
1
0
0
0
0
1
1
0
0
1
0
0
1
0
1
1
1
1
1
1
1
0
1
1
1
0
0
0
1
1
1
0
1
1
1
1
1
1
0
1
0
1
1
1
0
0
0
1
0
0
1
0
1
1
1
1
1
1
0
0
0
0
0
0
0
1
0
0
1
0
1
0
1
0
1
1
0
1
1
0
1
0
0
0
1
1
0
1
1
0
0
1
1
1
1
1
0
0
0
0
0
0
1
1
1
0
0
1
...

result:

ok 100000 numbers

Extra Test:

score: 0
Extra Test Passed