Codeforces 595B - Pasha and Phone
代码:
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back const int N=1e5+5; const int INF=0x3f3f3f3f; const int MOD=1e9+7; ll a[N]; int b[N]; int dp[11]={1}; int main() { ios::sync_with_stdio(false); cin.tie(0); int n,k; cin>>n>>k; for(int i=0;i<n/k;i++)cin>>a[i]; for(int i=0;i<n/k;i++)cin>>b[i]; for(int i=1;i<=k;i++)dp[i]=dp[i-1]*10; ll ans=1; for(int i=0;i<n/k;i++) { int t=0; ll n1=(dp[k]-1)/a[i]+1;//a[i]倍数的数量 ll n2=(dp[k-1]-1)/a[i]+1;//最高位为0的a[i]倍数的数量 ll n3=(dp[k-1]*(b[i]+1)-1)/a[i]-(dp[k-1]*b[i]-1)/a[i];//最高位为b[i]的a[i]的倍数的数量 if(b[i]==0)ans*=n1-n2; else ans*=n1-n3; ans%=MOD; } cout<<ans<<endl; return 0; }