Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <string>
- #include <queue>
- #include <map>
- #include <set>
- #include <string>
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define nl endl
- #define cy cout << "YES\n"
- #define cn cout << "NO\n"
- #define sz s.size()
- void sherry()
- {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- /*
- ll gcd(ll a, ll b)
- {
- while (b)
- {
- a %= b;
- swap(a, b);
- c++;
- }
- return a;
- }
- ll lcm(ll a, ll b)
- {
- return a * b / gcd(a, b);
- }
- bool is_prime(ll x)
- {
- if (x == 2 || x == 3)
- return true;
- if (x == 1 || x % 2 == 0)
- return false;
- for (ll i = 3; i <= sqrt(x); i += 2)
- {
- if (x % i == 0)
- return false;
- }
- return true;
- }*/
- int main()
- {
- sherry();
- // freopen("sort.in", "r", stdin);
- ll t;
- cin >> t;
- while (t--)
- {
- string n;
- bool flag = true;
- cin >> n;
- ll i = 0;
- while (flag)
- {
- string s = n;
- flag = false;
- for (ll i = 0; i < sz; i++)
- {
- if (s[i] - '0' != 0)
- {
- if (stoll(n) % (s[i] - '0') != 0)
- flag = true;
- }
- }
- n = to_string(stoll(n) + 1);
- }
- cout << stoll(n) - 1 << nl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement