Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <algorithm>
- #include <math.h>
- #include <vector>
- #include <fstream>
- using namespace std;
- int getSize(int x) {
- int l = 0;
- while (x > 0) {
- l++;
- x /= 10;
- }
- return l;
- }
- int countAmount(long long N, long long x) {
- int l = getSize(x);
- int p = pow(10, l);
- if (p % 10 != 0) p++;
- int myAns = 0;
- myAns = N/p;
- if ( N % p > x) {
- myAns++;
- }
- return myAns;
- }
- int main()
- {
- long long k = 0;
- long long M, N;
- cin >> M >> N;
- int t = pow(10, N);
- if (t % 10 != 0) t++;
- int d = pow(2, N);
- if (d % 2 != 0) d--;
- //cout << d << endl;
- long long ans = 0;
- for (int i = d; i < t; i+=d) {
- ans += countAmount(M, i);
- //cout << "i " << i << " ans " << ans << endl;
- }
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement