3930: [CQOI2015] selection | recursion | number theory

Source: Internet
Author: User

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&LT;=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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.