답안 #159436

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
159436 2019-10-22T17:12:38 Z theknife2001 Lun (COCI19_lun) C++17
40 / 50
3 ms 504 KB
#include <bits/stdc++.h>


using namespace std;
const int N=1e5+55;
string s;
int main()
{
	int n;
	cin>>n;
	cin>>s;
	reverse(s.begin(),s.end());
	int pos;
	for(int k=0;k<n;k++)
		if(s[k]=='x')
			pos=k;
	int sum=0;
	int x;
	for(int i=1;i<n;i+=2)
	{
		if(i==pos)
		continue ;
		x=s[i]-'0';
		x*=2;
		if(x>=10)
			x=x%10+x/10;
		sum+=x;
	}
	for(int i=2;i<n;i+=2)
	{
		if(i==pos)
		continue ;
		x=s[i]-'0';
		sum+=x;
	}
	for(int i=0;i<10;i++)
	{
		s[pos]=i+'0';
		if(pos==0)
		{
			cout<<(sum*9)%10<<endl;
			return 0;
		}
		if(pos%2)
		{
			x=i*2;
			if(x>=10)
			x=x/10+x%10;
			if(((sum+x)*9)%10==s[0]-'0')
			{
				cout<<i<<endl;
				return 0;
			}
		}
		if(((sum+i)*9)%10==s[0]-'0')
		{
			cout<<i<<endl;
			return 0;
		}
	}
		return 0;
}

Compilation message

lun.cpp: In function 'int main()':
lun.cpp:44:11: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if(pos%2)
           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Correct 3 ms 252 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Incorrect 2 ms 256 KB Output isn't correct
10 Correct 2 ms 376 KB Output is correct