| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 147254 | ipaljak | Lun (COCI19_lun) | C++14 | 3 ms | 376 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
typedef long long llint;
const int MOD = 1e9 + 7;
const int MAXN = 105;
int n;
char s[MAXN];
bool check(int x) {
int sum = 0;
for (int i = 1; i < n; ++i) {
int d = (s[n - i - 1] - '0');
if (s[n - i - 1] == 'x') d = x;
if (i % 2 == 1) d *= 2;
if (d >= 10) d = 1 + (d % 10);
sum += d;
}
sum *= 9; sum %= 10;
int val = s[n - 1] - '0';
if (s[n - 1] == 'x') val = x;
return sum == val;
}
int main(void) {
scanf("%d", &n);
scanf("%s", s);
for (int x = 0; x < 10; ++x) {
if (s[0] == 'x' && x == 0) continue;
if (check(x)) {
printf("%d\n", x);
break;
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
