UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#212820#3827. ABaron210230633ms1264kbC++11806b2024-10-20 11:48:152024-10-20 12:46:10

answer

#include <bits/stdc++.h>
using namespace std;
string zh(int a,int jz){
	string sum="";
	int i;
	for(i=0;a!=0;i++){
		sum=sum+char(a%jz+'0');
		a/=jz;
	}
	return sum;
}
bool jzjf(string i,string j,int zj){
	int siz;
	if(i.size()<j.size()) siz=i.size();
	else siz=j.size();
	for(int k=0;k<=siz;k++)
		if(int(i[k]-'0')+int(j[k]-'0')>=zj)
			return false;
	return true;
}
int main(){
//	freopen("A.in","r",stdin);
//	freopen("A.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++){
			string ii=zh(i,2);
			string jj=zh(j,2);
			if(jzjf(ii,jj,2)){
				string ii=zh(i,3);
				string jj=zh(j,3);
				if(jzjf(ii,jj,3)){
					ans+=2;
				}
			}
		}
	cout<<ans;
	return 0;
}

Details

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

Subtask #1:

score: 10
Accepted

Test #1:

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

input:

2

output:

0

result:

ok 1 number(s): "0"

Test #2:

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

input:

8

output:

6

result:

ok 1 number(s): "6"

Subtask #2:

score: 20
Accepted

Test #3:

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

input:

92

output:

348

result:

ok 1 number(s): "348"

Test #4:

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

input:

85

output:

316

result:

ok 1 number(s): "316"

Subtask #3:

score: 0
Time Limit Exceeded

Test #5:

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

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: