답안 #162784

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
162784 2019-11-09T17:34:40 Z 44442 Lun (COCI19_lun) C++11
50 / 50
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
int n,o,b,z[104],c,d,g,e,f;
char a[104];
int main (){
ios::sync_with_stdio(0);
     scanf("%d\n",&n);
     for(int i=n;i>0;i--){
         scanf("%c",&a[i]);
     	 if(a[i]==120){
     	     z[i]=1;
     	     o=i;
     	 }
	 }
	 for(int i=2;i<n+1;i=i+2){
	 	 if(!z[i]){
	 	 	 g=2*a[i]-96;
	 	 	 if(g>9)
	 	 	     g=g%10+1;
	 	     b=b+g;
	 	 }
	 }
	 for(int i=3;i<n+1;i=i+2){
	 	 if(!z[i])
	 	     b=b+a[i]-48;
	 }
	 if(o!=1){
		 c=b%10;
		 d=10-((a[1]-48)%10);
		 if(d>=c)
		     e=d-c;
		 else 
		     e=10-(c-d);
		 if(!(o%2)){
		     if(!(e%2))
		         printf("%d",e/2);
		     else
		         printf("%d", (e+9)/2);
		 }
		 else
		     printf("%d",e);
	 }
	 
	 else 		 
	     cout<<(b*9)%10;
return 0;
}

Compilation message

lun.cpp: In function 'int main()':
lun.cpp:7:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%d\n",&n);
      ~~~~~^~~~~~~~~~~
lun.cpp:9:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
          scanf("%c",&a[i]);
          ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 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 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct