UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212665#3827. Axxttcc30836ms1248kbC++839b2024-10-20 09:09:182024-10-20 12:35:51

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,sum;
bool f(int i,int j){
	int x1 = i,x2 = i;
	vector<int> a,b;
	while(x1 || x2){
		if(x1) a.push_back(x1 % 2);
		if(x2) b.push_back(x2 % 3);
		x1 /= 2;
		x2 /= 3;
	}
	int x3 = j,x4 = j;
	vector<int> c,d;
	while(x3 || x4){
		if(x3) c.push_back(x3 % 2);
		if(x4) d.push_back(x4 % 3);
		x3 /= 2;
		x4 /= 3;
	}
	int len1 = a.size(),len2 = c.size();
	for(int i = min(len1,len2) - 1;i >= 0;--i){
		if(a[i] + c[i] >= 2) return false;
	}
	int len3 = b.size(),len4 = d.size();
	for(int i = min(len3,len4) - 1;i >= 0;--i){
		if(b[i] + d[i] >= 3) return false;
	}
	return true;
}
int32_t main(){
	scanf("%lld",&n);
	for(int i = 1;i <= n;++i){
		for(int j = 1;j <= n;++j){
			if(f(i,j)) sum += 1;
		}
	}
	printf("%lld",sum);
	return 0;
}

详细

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

Subtask #1:

score: 10
Accepted

Test #1:

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

input:

2

output:

0

result:

ok 1 number(s): "0"

Test #2:

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

input:

8

output:

6

result:

ok 1 number(s): "6"

Subtask #2:

score: 20
Accepted

Test #3:

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

input:

92

output:

348

result:

ok 1 number(s): "348"

Test #4:

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

input:

85

output:

316

result:

ok 1 number(s): "316"

Subtask #3:

score: 0
Time Limit Exceeded

Test #5:

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

input:

939

output:

7730

result:

ok 1 number(s): "7730"

Test #6:

score: -20
Time Limit Exceeded

input:

994

output:


result:


Subtask #4:

score: 0
Time Limit Exceeded

Test #7:

score: 0
Time Limit Exceeded

input:

4375

output:


result: