QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#745659#9629. 小 C 的神秘图形AcorbeWA 0ms3732kbC++14793b2024-11-14 10:59:132024-11-14 10:59:14

Judging History

你现在查看的是最新测评结果

  • [2024-11-14 10:59:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3732kb
  • [2024-11-14 10:59:13]
  • 提交

answer

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

int A[3][3];

int sjz(string k);
int zs(int k)
{
	int cnt=1;
	for(int i=1;i<=k;i++)
		cnt*=3;
	return cnt;
}

int search(int a,int b,int k)
{
	if(k==1)
	{
		return A[a][b];
	}
	int z=zs(k-1);
	if((z<=a&&a<2*z)||(z<=b&&b<2*z))
	{
		return search(a%z,b%z,k-1);
	}
	else
		return 0;
}

int main()
{
	int n;
	string n1,n2;
	cin>>n;
	cin>>n1>>n2;
	int a=sjz(n1),b=sjz(n2);
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			if(i==1||j==1)
				A[i][j]=1;
			else
				A[i][j]=0;
		}
	}
	if(n==1)
		cout<<A[a][b];
	else
		cout<<search(a,b,n);
	return 0;
}

int sjz(string k)
{
	int l=k.length();
	int a=0,j=0;
	for(int i=l-1;i>=0;i--)
	{
		a+=(int(k[i])-48)*zs(j);
		j++;
	}
	return a;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3576kb

input:

96
122100012110202022211102020101110122101010001012220001000222210100222112111020002212000222012022
010112102102202201211121022102211110211010101020001021100101110202100010112221022001101222101102

output:

0

result:

ok single line: '0'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3732kb

input:

100
2101120010010021010112120010111111212001120112101221211001111101012021111111211111110120002210111111
1010111101111111121211011101011101111111011201111110112110001211101110200102102020021011111121221102

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'