UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212750#3827. Atwc1002019ms1252kbC++11550b2024-10-20 10:29:262024-10-20 12:41:09

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,cnt;
bool chk(int i,int j){
	string i3,j3;
	while(i){
  		i3=i3+char(i%3+'0');
		i/=3;
	}
	while(j){
		j3=j3+char(j%3+'0');
		j/=3;
	}
	for(int i=0;i<min(i3.size(),j3.size());i++){
		if(
		i3[i]=='2'&&j3[i]=='2'||
      	i3[i]=='1'&&j3[i]=='2'||
      	i3[i]=='2'&&j3[i]=='1'
		) return 0;
	}
	return 1;
}
int main(){
	cin>>n;
	for(int i=1;i<n;i++){
		for(int j=i;j<=n;j++){
			if((!(i&j))&&(chk(i,j))) cnt++;
		}
	}
	cout<<cnt*2;
    return 0;
}

详细

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

Subtask #1:

score: 10
Accepted

Test #1:

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

input:

2

output:

0

result:

ok 1 number(s): "0"

Test #2:

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

input:

8

output:

6

result:

ok 1 number(s): "6"

Subtask #2:

score: 20
Accepted

Test #3:

score: 20
Accepted
time: 0ms
memory: 1248kb

input:

92

output:

348

result:

ok 1 number(s): "348"

Test #4:

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

input:

85

output:

316

result:

ok 1 number(s): "316"

Subtask #3:

score: 20
Accepted

Test #5:

score: 20
Accepted
time: 19ms
memory: 1248kb

input:

939

output:

7730

result:

ok 1 number(s): "7730"

Test #6:

score: 0
Accepted
time: 15ms
memory: 1248kb

input:

994

output:

7994

result:

ok 1 number(s): "7994"

Subtask #4:

score: 50
Accepted

Test #7:

score: 50
Accepted
time: 328ms
memory: 1248kb

input:

4375

output:

58626

result:

ok 1 number(s): "58626"

Test #8:

score: 0
Accepted
time: 398ms
memory: 1248kb

input:

4594

output:

66410

result:

ok 1 number(s): "66410"

Test #9:

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

input:

4989

output:

74836

result:

ok 1 number(s): "74836"

Test #10:

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

input:

4877

output:

73756

result:

ok 1 number(s): "73756"

Test #11:

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

input:

4790

output:

72308

result:

ok 1 number(s): "72308"

Extra Test:

score: 0
Extra Test Passed