Test instructions
The test instructions of this English question is slightly complicated.
Find out how many sequences of numbers are of length n. This sequence can be divided into n/k segments, each with a K-number. The number of K can be changed to a decimal number XI. Requires that the number of each n/k, excluding XI can be divided by AI, excluding the first number of X (including the leading 0) is the case of BI. Ask how many of the remaining combinations are.
Ideas:
I am a twists of this question. First also did not consider a lot, watching can be violent simulation process, I directly began to knock, a few for the loop knocked out, and then the bug tune a special case to consider, after the start of the tle, when the realization of the complexity is too large, and began to optimize, did (B[i]) * (MMAX/10)-1 ~ (b[i]+1) * (MMAX/10)-1 of the Cycle range optimization, the latter case again timed out, and later felt that should not be violent simulation, notice that a certain range can be divisible by a number of numbers can be calculated by the formula, which is directly computed with the formula to eliminate the For loop, this is only over the problem.
#include <cstdio>#include<cstring>#include<iostream>using namespacestd;#defineMAX (x, Y) (((x) > (y))? (x): (y))#defineMIN (x, Y) ((() < (y))? (x): (y))#defineABS (x) ((x) >0? ( x):-(x))Const intINF =0x7fffffff;Const intn=100000+Ten;Const Long Longmod=1e9+7;intA[n];intB[n];intMain () {//freopen ("OUT.txt", "w", stdout); intN; intK; CIN>>n>>K; intkk=K; Long Longmmax=1; while(kk--) Mmax*=Ten;//cout<<mmax; intnum=n/K; for(intI=0; i<num; i++) scanf ("%d", A +i); for(intI=0; i<num; i++) scanf ("%d", B +i); Long Longans=1; for(intI=0; i<num; i++) { Long LongCnt= (mmax-1)/a[i]+1; if(B[i] = =0) {CNT-= (mmax/Ten-1)/a[i]+1; } Else{cnt=cnt-(((b[i]+1) * (mmax/Ten)-1)/a[i]+1) + (((B[i]) * (mmax/Ten)-1)/a[i]+1 ); } ans=ans*cnt%MoD; } cout<<ans<<Endl; return 0;}
Essay-Pre-invitational training-codeforces Round #330 (Div. 2) Question B