답안 #104100

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104100 2019-04-04T03:09:35 Z wiritos1 Lun (COCI19_lun) C++
50 / 50
2 ms 384 KB
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	int a;
	string b;
	cin>>a>>b;
	bool p2=false;
	int sum=0;
	for(int c=0;c<a-1;c++)
	{
		if(b[c]=='x')
		{
			if(c%2==(a-1)%2)
			{
				p2=false;
			}
			else
			{
				p2=true;
			}
		}
		else
		{
			if(c%2==(a-1)%2)
			{
				sum+=b[c]-'0';
			}
			else
			{
				if(b[c]<'5')
				{
					sum+=(b[c]-'0')*2;
				}
				else
				{
					sum+=((b[c]-'5')*2)+1;
				}
			}
		}
		//cout<<sum<<" ";
	}
	int temi;
	//cout<<sum<<"s"<<'\n';
	for(int ga=0;ga<=9;ga++)
	{
		if(p2)
		{
			temi=ga*2;
			if(temi>=10)
			{
				temi%=10;
				temi++;
			}
		}
		else
		{
			temi=ga;
		}
		//cout<<temi<<" ";
		temi+=sum;
		temi*=9;
		temi%=10;
		//cout<<temi<<" "<<b[a-1]<<'\n';
		if(b[a-1]=='x')
		{
			if((sum*9)%10==ga)
			{
				cout<<ga;
				return 0;
			}
		}
		else
		{
			if(temi==b[a-1]-'0')
			{
				cout<<ga;
				return 0;
			}
		}
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct