fork download
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long ll;
  6.  
  7. int main ()
  8. {
  9. ll n, k, x, i, j, l, cnt=0, cnt1=0, cnt2=0, cnt3=0, num=0;
  10. cin >> n >> k;
  11. x=n/k;
  12. double power=pow(10.0, (double)k);
  13. ll p=power;
  14. power=pow(10.0, (double)(k-1));
  15. ll q=power;
  16. //cout << p;
  17. ll a[x], b[x], c[x];
  18. for (i=0; i<x; i++) cin >> a[i];
  19. for (i=0; i<x; i++) cin >> b[i];
  20. if (n==1 && a[0]==1)
  21. {
  22. cout << 9;
  23. return 0;
  24. }
  25. for (i=0; i<x; i++)
  26. {
  27. cnt=0;
  28. //j=1;
  29. num=a[i];
  30. ll h=num;
  31. cnt1=(p-1)/a[i];
  32. if (b[i]==0)
  33. {
  34. //cout << q-1 << endl;
  35. cnt2=(q-1)/a[i];
  36. }
  37. else
  38. {
  39. cnt2=((b[i]+1)*q-1)/a[i]-(b[i]*q-1)/a[i];
  40. }
  41. //cout << cnt1 << " " << cnt2;
  42. cnt=cnt1-cnt2;
  43. //int o=num;
  44. /*while(h/10!=0)
  45.   {
  46.   h/=10;
  47.   }*/
  48. //h/=q;
  49. //if (h!=b[i]) cnt++;
  50. //cout << h << endl;
  51. //j++;
  52. //num=a[i]*j;
  53. //cout << num << endl;
  54. if (b[i]==0) c[i]=cnt;
  55. else c[i]=cnt+1;
  56. }
  57. /*for (i=0; i<x; i++)
  58.   {
  59.   cout << a[i] << " ";
  60.   }
  61.   for (i=0; i<x; i++)
  62.   {
  63.   cout << b[i] << " ";
  64.   }*/
  65. /*for (i=0; i<x; i++)
  66.   {
  67.   cout << c[i] << " ";
  68.   }*/
  69. ll ans=1;
  70. for (i=0; i<x; i++)
  71. {
  72. ll r=c[i];
  73. ans=ans*r;
  74. ans=ans%1000000007;
  75. //cout << ans << endl;
  76. }
  77. cout << ans;
  78. return 0;
  79. }
Success #stdin #stdout 0s 3416KB
stdin
8 2
1 22 3 44
5 4 3 2
stdout
32400