Submission #314123

#TimeUsernameProblemLanguageResultExecution timeMemory
314123phathnvLun (COCI19_lun)C++11
50 / 50
1 ms384 KiB
#include <bits/stdc++.h> #define mp make_pair #define X first #define Y second #define taskname "LUN" using namespace std; typedef long long ll; typedef pair <int, int> ii; int n; string s; void readInput(){ cin >> n >> s; } bool valid(){ int sum = 0; for(int i = 0; i < n - 1; i++){ int tmp = s[i] - '0'; if ((i + n - 1) & 1) tmp <<= 1; sum += tmp / 10 + tmp % 10; } return (sum * 9 % 10 == s[n - 1] - '0'); } void solve(){ int p = s.find('x'); for(char ch = '0'; ch <= '9'; ch++){ s[p] = ch; if (valid()){ cout << ch; return; } } assert(0); } int main(){ if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } readInput(); solve(); return 0; }

Compilation message (stderr)

lun.cpp: In function 'int main()':
lun.cpp:45:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   45 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
lun.cpp:46:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   46 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...