UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212672#3827. AGeorgesihan50567ms1244kbC++982b2024-10-20 09:17:192024-10-20 12:36:22

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,cnt;
string s,t;
bool f,g;
string llto2(ll a){
	string ans;
	do{
		ans+=(a%2)+'0';
		a/=2;
	}while(a>0);
	return ans;
}
string llto3(ll a){
	string ans;
	do{
		ans+=(a%3)+'0';
		a/=3;
	}while(a>0);
	return ans;
}
int main(){
	cin>>n;
	for(ll i=1;i<=n;i++){
		for(ll j=i;j<=n;j++){
			s=llto2(i),t=llto2(j);
			ll lent=t.size(),lens=s.size();
			while(s.size()<lent){
				s+='0';
			}
			for(ll k=0;k<lent;k++){
				if(s[k]+t[k]-'0'*2>=2){
					f++;
					break;
				}
				if(k==lens) break;
			}
			if(f==1){
				f=0;
				continue;
			}
			s=llto3(i),t=llto3(j);
			lent=t.size(),lens=s.size();
			while(s.size()<lent){
				s+='0';
			}
			for(ll k=0;k<lent;k++){
				if(s[k]+t[k]-'0'*2>=3){
					g++;
					break;
				}
				if(k==lens) break;
			}
			if(g==1){
				g=0;
				continue;
			}
			cnt++;
			f=0;g=0;
		}
	}
	cout<<cnt*2;
	return 0;
}


详细

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

Subtask #1:

score: 10
Accepted

Test #1:

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

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: 5ms
memory: 1244kb

input:

92

output:

348

result:

ok 1 number(s): "348"

Test #4:

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

input:

85

output:

316

result:

ok 1 number(s): "316"

Subtask #3:

score: 20
Accepted

Test #5:

score: 20
Accepted
time: 301ms
memory: 1240kb

input:

939

output:

7730

result:

ok 1 number(s): "7730"

Test #6:

score: 0
Accepted
time: 257ms
memory: 1240kb

input:

994

output:

7994

result:

ok 1 number(s): "7994"

Subtask #4:

score: 0
Time Limit Exceeded

Test #7:

score: 0
Time Limit Exceeded

input:

4375

output:


result: