1 #include <iostream> 2 #include <cstdio> 3 using namespace std; 4 5 typedef long long ll; 6 7 const ll MAXN = 1e18; 8 9 ll n, s; 10 11 bool check(ll x) 12 { 13 ll sum = 0; 14 ll tmp = x; 15 while (x) 16 { 17 sum += x % 10; 18 x /= 10; 19 } 20 return tmp - sum >= s; 21 } 22 23 int main() 24 { 25 cin >> n >> s; 26 ll l = 0, r = MAXN + 1, res = MAXN + 1; 27 while (l <= r) 28 { 29 ll m = (l + r) >> 1; 30 if (check(m)) r = m - 1, res = m; 31 else l = m + 1; 32 } 33 cout << (n >= res ? n - res + 1 : 0) << endl; 34 return 0; 35 }
CF817C Really Big Numbers
内容版权声明:除非注明,否则皆为本站原创文章。