UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212659#3827. AAlex98763015ms1248kbC++1.3kb2024-10-20 09:02:482024-10-20 12:35:29

answer

#include<bits/stdc++.h>
std::string turn(int number,int digit)//转换 
{
	std::string result="";
	std::string num="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	while(number>0)
	{
		result=num[number%digit]+result;
		number=number/digit;
	}
	return result;
}
int main()
{
	int mx;
	int total=0;
	std::cin>>mx;
	for(int a=1;a<mx+1;a+=1)
	{
		for(int b=a+1;b<mx+1;b+=1)
		{
			int ok_1=1;
			std::string a_1=turn(a,2);
			std::string b_1=turn(b,2);
			std::string c_1=turn(a+b,2);//开始模拟加法(二进制)
			if(a_1.size()<b_1.size()){a_1=std::string(b_1.size()-a_1.size(),'0')+a_1;}
			else{b_1=std::string(a_1.size()-b_1.size(),'0')+b_1;}
			for(int y=0;y<a_1.size();y+=1)
			{
				int res=a_1[y]+b_1[y]-48*2;
				if(res>1)
				{
					ok_1=0;
					break;
				}
			}
			if(ok_1==0){continue;}
			int ok_2=1;
			std::string a_2=turn(a,3);
			std::string b_2=turn(b,3);
			std::string c_2=turn(a+b,3);//开始模拟加法(三进制)
			if(a_2.size()<b_2.size()){a_2=std::string(b_2.size()-a_2.size(),'0')+a_2;}
			else{b_2=std::string(a_2.size()-b_2.size(),'0')+b_2;}
			for(int y=0;y<a_2.size();y+=1)
			{
				int res=a_2[y]+b_2[y]-48*2;
				if(res>2)
				{
					ok_2=0;
					break;
				}
			}
			if(ok_2==0){continue;}
			total+=2;
		}
	}
	std::cout<<total;
	return 0;
} 

详细

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

Subtask #1:

score: 10
Accepted

Test #1:

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

input:

2

output:

0

result:

ok 1 number(s): "0"

Test #2:

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

input:

8

output:

6

result:

ok 1 number(s): "6"

Subtask #2:

score: 20
Accepted

Test #3:

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

input:

92

output:

348

result:

ok 1 number(s): "348"

Test #4:

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

input:

85

output:

316

result:

ok 1 number(s): "316"

Subtask #3:

score: 0
Time Limit Exceeded

Test #5:

score: 0
Time Limit Exceeded

input:

939

output:


result:


Subtask #4:

score: 0
Time Limit Exceeded

Test #7:

score: 0
Time Limit Exceeded

input:

4375

output:


result: