cosenza987

asdasdas

Apr 11th, 2021
705
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. #include <stdio.h>
  4. #include <math.h>
  5. #include <cmath>
  6. #include <string>
  7.  
  8. #define mod 1000000007
  9.  
  10. using namespace std;
  11.  
  12. long long sum(long long n, long long m) {
  13.     map<int, int> bruh;
  14.     map<int, int> res;
  15.     string s1 = to_string(n);
  16.     int q = s1.size();
  17.     for(int i = 0; i < q; i++) {
  18.         int swap = s1[i] - '0';
  19.         bruh[swap]++;
  20.     }
  21.     for(int i = 0; i < m; i++) {
  22.         for(int j = 0; j < 10; j++) {
  23.             if(j != 9) {
  24.                 res[j + 1] = bruh[j];
  25.             } else {
  26.                 int vai = bruh[j];
  27.                 res[1] = (res[1] + vai) % mod;
  28.                 res[0] = (res[0] + vai) % mod;
  29.             }
  30.         }
  31.         for(int j = 0; j < 10; j++) {
  32.             bruh[j] = res[j];
  33.             res[j] = 0;
  34.         }
  35.     }
  36.     int sum = 0;
  37.     for(int i = 0; i < 10; i++) {
  38.         sum = (sum + bruh[i]) % mod;
  39.     }
  40.     return sum;
  41. }
  42.  
  43. int main() {
  44.     int t;
  45.     long long n, m;
  46.     scanf("%d", &t);
  47.     while(t--) {
  48.         scanf("%lld %lld", &n, &m);
  49.         long long res = sum(n, m);
  50.         printf("%d\n", res);
  51.     }
  52.     return 0;
  53. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×