标签:www. string algorithm show problem 暴力 noip ret turn
差分+暴力
1 #include<cstdio> 2 #include<cstdlib> 3 #include<algorithm> 4 #include<cstring> 5 #define MAXN 80005 6 #define ll long long 7 using namespace std; 8 ll read(){ 9 ll x=0,f=1;char ch=getchar(); 10 while(ch<‘0‘||ch>‘9‘){if(‘-‘==ch)f=-1;ch=getchar();} 11 while(ch>=‘0‘&&ch<=‘9‘){x=x*10+(ch^48);ch=getchar();} 12 return x*f; 13 } 14 ll a[MAXN],b[MAXN]; 15 int c[MAXN]; 16 int n,MOD,minT,maxT; 17 int main() 18 { 19 // freopen("data.in","r",stdin); 20 n=read(); 21 int T=read(); 22 MOD=read(),minT=read(),maxT=read(); 23 char ch[5]={0}; 24 while(T--){ 25 scanf("%s",ch); 26 int l=read(),r=read(); 27 if(‘A‘==ch[0]){ 28 int x=read(); 29 a[l]+=x,a[r+1]-=x; 30 } 31 else{ 32 for(int i=1;i<=n;i++){ 33 b[i]=a[i]+b[i-1]; 34 } 35 int ans=0; 36 for(int i=l;i<=r;i++){ 37 int t=b[i]%MOD*i%MOD; 38 if(minT<=t&&t<=maxT){ 39 ans++; 40 } 41 } 42 printf("%d\n",ans); 43 } 44 } 45 for(int i=1;i<=n;i++){ 46 b[i]=a[i]+b[i-1]; 47 } 48 for(int i=1;i<=n;i++){ 49 int t=b[i]%MOD*i%MOD; 50 c[i]=c[i-1]+(minT<=t&&t<=maxT); 51 } 52 T=read(); 53 while(T--){ 54 int l=read(),r=read(); 55 printf("%d\n",c[r]-c[l-1]); 56 } 57 return 0; 58 }
标签:www. string algorithm show problem 暴力 noip ret turn
原文地址:http://www.cnblogs.com/w-h-h/p/7780503.html