Topic let's ask from the interval [L,H] Can be selected repeatedly in the n Number makes it < Span class= "Mrow" id= "mathjax-span-5310" >g c d = The number of scenarios
The transformation is the range [? L k ?,? H k ?] Can be selected repeatedly in the n Number makes it < Span class= "Mrow" id= "mathjax-span-5335" >g c d = 1 The number of scenarios
And then F[i] Said gcd=i The number of scenarios, consider removing all the numbers are duplicates, this situation finally in the judgement Plus
F [I]=sum? ∑ i| J F [J]
#include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <vector>#include <cmath>#include <queue>#include <set>#include <map>#define LL Long Long#define MOD 1000000007 //2 3 4679 35617 #define N 100051using namespace STD;intSC () {intI=0, f=1;CharC=getchar (); while(c>' 9 '|| c<' 0 '){if(c=='-') f=-1; C=getchar ();} while(c>=' 0 '&&c<=' 9 ') i=i*Ten+c-' 0 ', C=getchar ();returnI*f;}Long LongF[n],n,k,a,b;Long LongCal (ll X,ll y) {Long Longres=1; for(; y;x=x*x%mod,y>>=1)if(y&1) Res=res*x%mod;returnRes;}intMain () {scanf("%d%d%d%d", &n,&k,&a,&b);intl=a/k,r=b/k;if(a%k) l++; for(inti=b-a;i;i--) {intl=l/i,r=r/i;if(l%i) l++;if(L<=R) {f[i]= (Cal (r-l+1, N)-(r-l+1))%mod; for(intj=i*2; j<=b-a;j+=i) f[i]= (f[i]-f[j])%mod; } }if(l==1) f[1]++;printf("%d", (f[1]+MOD)%mod);return 0;}
3930: [CQOI2015] selection | recursion | number theory