CF-1004-C. Devyatkino · znzryb
## 思路讲解
[https://codeforces.com/blog/entry/139415?locale=en](https://codeforces.com/blog/entry/139415?locale=en)

就只看最后一位数(因为最后一位数不会有进位什么的问题),就可以得到最多不会超过9次的结论
然后就直接暴力就好了,不知道题解后面在写什么
## AC代码
[https://codeforces.com/contest/2067/submission/305782258](https://codeforces.com/contest/2067/submission/305782258)
```cpp
// Problem: C. Devyatkino
// Contest: Codeforces - Codeforces Round 1004 (Div. 2)
// URL: https://codeforces.com/contest/2067/problem/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// by znzryb
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define ROF(i, a, b) for (int i = (a); i >= (b); --i)
#define all(x) x.begin(), x.end()
#define CLR(i, a) memset(i, a, sizeof(i))
#define fi first
#define se second
#define pb push_back
#define SZ(a) ((int)a.size())
#define LOCAL
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef array<ll, 3> arr;
typedef double DB;
typedef pair<DB, DB> pdd;
constexpr ll MAXN = static_cast<ll>(1e6) + 10, INF = static_cast<ll>(5e18) + 3;
ll N, T;
ll pow10[20];
inline void solve() {
ll x;
cin >> x;
ll ans = 9;
string s = to_string(x);
N = SZ(s);
FOR(i, 0, N - 1) {
if (s[i] == '7') {
cout << 0 << '\n';
return;
}
}
FOR(i, 1, N + 1) {
ll add = pow10[i] - 1;
ll t = x;
FOR(j, 1, ans) {
t += add;
string ts = to_string(t);
bool isBreak = false;
FOR(k, 0, SZ(ts) - 1) {
if (ts[k] == '7') {
ans = j;
// #ifdef LOCAL
// FOR(lk, 0, SZ(ts) - 1) { cerr << ts[lk]; }
// cerr << '\n';
// #endif
isBreak = true;
break;
}
}
if (isBreak) break;
}
}
cout << ans << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> T;
pow10[0] = 1;
FOR(i, 1, 18) { pow10[i] = pow10[i - 1] * 10; }
while (T--) {
solve();
// #ifdef LOCAL
// cerr << '\n';
// #endif
}
return 0;
}
/*
AC
https://codeforces.com/contest/2067/submission/305782258
*/
```
## 心路历程(WA,TLE,MLE……)