UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212657#3827. A15523597526100624ms1264kbC++11932b2024-10-20 09:01:072024-10-20 12:35:22

answer

#include <bits/stdc++.h>
#define ll long long
#define db(s,a) cout << s << ":" << a << endl
#define dbarr(a,n) for(ll i=1;i<=n;i++) cout << a[i] << " " ; cout << endl ;
#define isok cout << "ok" << endl
using namespace std ;
ll l , n , i , j , cnt ;
vector<ll> b , t ;
bool check(ll n , ll m){
	b.clear() ;
	t.clear() ;
	l = 0 ;
	while((1 << l)<=min(n,m)){
		if(n&(1 << l) && m&(1 << l)){
			return false ;
		}
		l++ ;
	}
	while(n){
		b.push_back(n%3) ;
		n /= 3 ;
	}
	while(m){
		t.push_back(m%3) ;
		m /= 3 ;
	}
	for(ll i=0;i<(ll)min(b.size(),t.size());i++){
		if(b[i]+t[i]>=3){
			return false ;
		}
	}
	return true ;
}
int main(){
//	freopen(".in","r",stdin) ;
//	freopen(".out","w",stdout) ;
	ios::sync_with_stdio(false) ;
	cin.tie(0) ;
	cout.tie(0) ;
	cin >> n ;
	for(i=1;i<=n;i++){
		for(j=1;j<=i;j++){
			if(check(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: 1256kb

input:

8

output:

6

result:

ok 1 number(s): "6"

Subtask #2:

score: 20
Accepted

Test #3:

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

input:

92

output:

348

result:

ok 1 number(s): "348"

Test #4:

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

input:

85

output:

316

result:

ok 1 number(s): "316"

Subtask #3:

score: 20
Accepted

Test #5:

score: 20
Accepted
time: 6ms
memory: 1260kb

input:

939

output:

7730

result:

ok 1 number(s): "7730"

Test #6:

score: 0
Accepted
time: 6ms
memory: 1264kb

input:

994

output:

7994

result:

ok 1 number(s): "7994"

Subtask #4:

score: 50
Accepted

Test #7:

score: 50
Accepted
time: 99ms
memory: 1264kb

input:

4375

output:

58626

result:

ok 1 number(s): "58626"

Test #8:

score: 0
Accepted
time: 109ms
memory: 1260kb

input:

4594

output:

66410

result:

ok 1 number(s): "66410"

Test #9:

score: 0
Accepted
time: 131ms
memory: 1260kb

input:

4989

output:

74836

result:

ok 1 number(s): "74836"

Test #10:

score: 0
Accepted
time: 154ms
memory: 1264kb

input:

4877

output:

73756

result:

ok 1 number(s): "73756"

Test #11:

score: 0
Accepted
time: 119ms
memory: 1264kb

input:

4790

output:

72308

result:

ok 1 number(s): "72308"

Extra Test:

score: 0
Extra Test Passed