Submission #224926

#TimeUsernameProblemLanguageResultExecution timeMemory
224926kartelLun (COCI19_lun)C++14
50 / 50
5 ms384 KiB
#include <bits/stdc++.h> #define in(x) freopen(x,"r",stdin) #define out(x) freopen(x,"w",stdout) #define F first #define S second #define pb push_back #define M ll(998244353) #define inf ll(2e9+7) #define N ll(200500) #define sz(x) x.size() //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("O3") //#pragma GCC optimize("Ofast") #define el '\n' using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ld; //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //using namespace __gnu_pbds; //typedef tree <ll, null_type, less_equal <ll>, rb_tree_tag, tree_order_statistics_node_update> os; char x; string s, t; int n, i, j; int main() { // in("input.txt"); // out("output.txt"); ios_base::sync_with_stdio(false); iostream::sync_with_stdio(false); cin.tie(NULL); cin >> n >> s; i = 0; while (i < n && s[i] != 'x') i++; if (i == 0) x = '1'; else x = '0'; for (; x <= '9'; x++) { t = s; t[i] = x; for (j = n - 2; j >= 0; j -= 2) { int y = t[j] - '0'; if (y != 0) { y *= 2; y %= 9; if (y == 0) y = 9; } t[j] = char(y + '0'); } // cerr << t << el; int sum = 0; for (j = 0; j < n - 1; j++) sum += t[j] - '0'; if ((sum * 9) % 10 == int(t[n - 1] - '0')) { cout << x; return 0; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...