File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ #pragma GCC optimize("Ofast")
2+ #pragma GCC optimize("unroll-loops")
3+ #include < bits/stdc++.h>
4+ using namespace std ;
5+
6+ typedef long long ll;
7+ #define fast_cin () \
8+ ios_base::sync_with_stdio (false ); \
9+ cin.tie(NULL ); \
10+ cout.tie(NULL );
11+
12+ ll best;
13+ void can (ll n, ll j) {
14+ for (ll i = 0 ; i <= 6 ; i++) {
15+ ll x = n + i * j;
16+ while (x) {
17+ if (x % 10 == 7 ) {
18+ best = min (best, i);
19+ return ;
20+ };
21+ x /= 10 ;
22+ }
23+ }
24+ }
25+
26+ int main () {
27+ fast_cin ();
28+ int tc;
29+ cin >> tc;
30+ while (tc--) {
31+ ll n;
32+ cin >> n;
33+ best = 7 ;
34+
35+ can (n, 9LL );
36+ can (n, 99LL );
37+ can (n, 999LL );
38+ can (n, 9999LL );
39+ can (n, 99999LL );
40+ can (n, 999999LL );
41+ can (n, 9999999LL );
42+ can (n, 99999999LL );
43+ can (n, 999999999LL );
44+ cout << best << endl;
45+ }
46+
47+ return 0 ;
48+ }
You can’t perform that action at this time.
0 commit comments