UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212700#3827. Awyc6326Compile Error//C++1.0kb2024-10-20 09:48:132024-10-20 12:38:16

answer

#include<bits/stdc++.h>
using namespace std;

template<class A,class B>
B trans(const A &a)
{
	stringstream st;
	st<<a;
	B b;
	st>>b;
	return b;
}
int trans1(int n)
{
	int ans=0,cur=1;
	while(n)
	{
		//305
		ans=ans+n%2*cur;
		n/=2;
		cur*=10;
	}
	string tmp=trans<int,string>(ans);
	return trans<string,int>(tmp);
}
int trans2(int n)
{
	int ans=0,cur=1;
	while(n)
	{
		//3
		ans=ans+n%3*cur;
		n/=3;
		cur*=10;
	}
	string tmp=trans<int,string>(ans);
	return trans<string,int>(tmp);
}
int main()
{
	//freopen("A.in","r",stdin);
	//freopen("A.out","w",stdout);
	int n;scanf("%d",&n);
	bool flag=0;
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			flag=1;
			//(i,j)
			int i2=trans1(i);
			int i3=trans2(i);
			int j2=trans1(j);
			int j3=trans2(j);
			for(char c:to_string(i2+j2)) //10+100
			{
				if(c-'0'>=2) flag=0;
			}
			for(char c:to_string(i3+j3)) //2+11
			{
				if(c-'0'>=3&&flag) flag=0;
			}
			if(flag) cnt++;
		}
	}
	printf("%d",cnt);
	return 0;
}

详细

answer.code: In function 'int main()':
answer.code:56:15: error: range-based 'for' loops are not allowed in C++98 mode
    for(char c:to_string(i2+j2)) //10+100\x0d
               ^
answer.code:56:30: error: 'to_string' was not declared in this scope
    for(char c:to_string(i2+j2)) //10+100\x0d
                              ^
answer.code:60:15: error: range-based 'for' loops are not allowed in C++98 mode
    for(char c:to_string(i3+j3)) //2+11\x0d
               ^
answer.code:43:22: warning: ignoring re...