ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#213105 | #584. t3 | jax | 0 | 11616ms | 18248kb | C++ | 3.0kb | 2024-11-09 20:07:24 | 2024-11-09 23:11:40 |
answer
#include<bits/stdc++.h>
using namespace std;
namespace io{
char buf[1<<20],*p1=buf,*p2=buf;
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin)),p1==p2?EOF:*p1++)
int read(){
int x=0,f=0;char c=gc();
while(c< '0'||c> '9') f|=c=='-',c=gc();
while(c>='0'&&c<='9') x=x*10+(c^48),c=gc();
return f?-x:x;
}
char pbuf[1<<20],*pp=pbuf;
#define flush() (fwrite(pbuf,1,pp-pbuf,stdout),pp=pbuf)
#define pc(ch) (pp==pbuf+(1<<20)&&flush(),*pp++=(ch))
class Flush{public:~Flush(){flush();}}_;
void write(int x,char ch=0){
if(x<0) pc('-'),x=-x;
static int st[35];int top=0;
do st[top++]=x%10,x/=10;while(x);
while(top) pc(st[--top]^48);if(ch) pc(ch);
}
void putc(char ch){pc(ch);}
}
#define ll long long
#define N 100009
const int mo=1000000007;
const int C[11][11]={
{1,0,0,0,0,0,0,0,0,0,0,},
{1,1,0,0,0,0,0,0,0,0,0,},
{1,2,1,0,0,0,0,0,0,0,0,},
{1,3,3,1,0,0,0,0,0,0,0,},
{1,4,6,4,1,0,0,0,0,0,0,},
{1,5,10,10,5,1,0,0,0,0,0,},
{1,6,15,20,15,6,1,0,0,0,0,},
{1,7,21,35,35,21,7,1,0,0,0,},
{1,8,28,56,70,56,28,8,1,0,0,},
{1,9,36,84,126,126,84,36,9,1,0,},
{1,10,45,120,210,252,210,120,45,10,1,},
};
int qp(int a,int b){
int r=1;
for(;b;b>>=1,a=(ll)a*a%mo)
if(b&1) r=(ll)r*a%mo;
return r;
}
struct node{int l,r,k,x,s[11];};
struct sgt{
#define p1 p<<1
#define p2 p<<1|1
#define mid (t[p].r+t[p].l)>>1
#define len(x) (t[x].r-t[x].l+1)
node t[N*4];
void update(int p){
for(int i=0;i<=10;i++)
t[p].s[i]=t[p1].s[i]+t[p2].s[i];
}
void f(int p,int k,int x){
if(x!=-1){
t[p].k=k;t[p].x=x;
x=(x+k)%mo;
for(int i=0;i<=10;i++)
t[p].s[i]=(ll)len(p)*qp(x,i)%mo;
}else{
t[p].k=(t[p].k+k)%mo;
for(int i=10;i>=0;i--)
for(int j=i-1,ki=1;j>=0;j--)
ki=(ll)ki*k%mo,t[p].s[i]=(t[p].s[i]+(ll)t[p].s[j]*C[i][j]%mo*ki)%mo;
}
}
void pushdown(int p){
int k=t[p].k;
int x=t[p].x;
f(p1,k,x);
f(p2,k,x);
t[p].k=0;
t[p].x=-1;
}
void build(int p,int l,int r,int *a){
t[p].l=l,t[p].r=r,t[p].k=0,t[p].x=-1;
if(l==r){
for(int i=0;i<=10;i++)
t[p].s[i]=qp(a[l],i);
return;
}
int m=mid;
build(p1,l,m,a);
build(p2,m+1,r,a);
update(p);
}
int ask(int p,int l,int r,int i){
if(l<=t[p].l&&t[p].r<=r)
return t[p].s[i];
int m=mid,ret=0;
pushdown(p);
if(l<=m) ret=(ret+ask(p1,l,r,i))%mo;
if(r> m) ret=(ret+ask(p2,l,r,i))%mo;
return ret;
}
void chg(int p,int l,int r,int k,int x){
if(l<=t[p].l&&t[p].r<=r){
f(p,k,x);
return;
}
int m=mid;
pushdown(p);
if(l<=m) chg(p1,l,r,k,x);
if(r> m) chg(p2,l,r,k,x);
update(p);
}
}t;
int a[N];
int main(){
// freopen("in.in","r",stdin);
int n,m;
n=io::read();
m=io::read();
for(int i=1;i<=n;i++) a[i]=io::read();
t.build(1,1,n,a);
while(m--){
int o,l,r,x;
x=(x+mo)%mo;
o=io::read();
l=io::read();
r=io::read();
x=io::read();
if(o==1) t.chg(1,l,r,x,-1);
else if(o==2) t.chg(1,l,r,0,x);
else io::write(t.ask(1,l,r,x),'\n');
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Wrong Answer
time: 8ms
memory: 1252kb
input:
458 823 14431 9895 11970 15308 2575 20181 709 27999 12992 18884 11061 16281 5044 28990 25092 28337 3...
output:
-107704750 842747838 581509507 903754571 86349057 19400072 -244262904 -40406246 741787988 6661746 84...
result:
wrong answer 1st lines differ - expected: '806084096', found: '-107704750'
Test #2:
score: 0
Wrong Answer
time: 5ms
memory: 1248kb
input:
481 526 8409 14498 18636 10027 24362 32458 17986 17730 11956 19192 2193 1034 29317 19284 16210 26242...
output:
-327207496 -822341289 748704002 320452351 133 -156667990 181493288 921520769 182572597 13400037 6793...
result:
wrong answer 1st lines differ - expected: '867105097', found: '-327207496'
Test #3:
score: 0
Wrong Answer
time: 1712ms
memory: 18192kb
input:
100000 100000 15247 4194 9619 4532 22058 2667 21549 16652 25327 12018 13395 11426 7243 11714 22904 2...
output:
54433 544457741 352487648 82525935 532381851 235929450 38218 30045720 19138 459644406 33559 30953524...
result:
wrong answer 23rd lines differ - expected: '391361376', found: '96394108'
Test #4:
score: 0
Wrong Answer
time: 1567ms
memory: 18188kb
input:
100000 100000 6264 26207 28424 24165 4852 20798 5803 18679 24588 12238 25786 28622 19900 101 25922 2...
output:
18923 13111195 41716 34447 32091 80654 731180277 9973 523560023 19797 159789457 695071461 3136 95363...
result:
wrong answer 908th lines differ - expected: '567988', found: '705600727'
Test #5:
score: 0
Wrong Answer
time: 1569ms
memory: 18212kb
input:
100000 100000 15043 9299 7163 25384 24996 3803 24356 12466 22073 12987 8931 14997 3951 32704 23076 8...
output:
-743032134 6296 588341566 556164348 180064833 683 996777088 63953 57030 17635 175222109 5280 57193 3...
result:
wrong answer 1st lines differ - expected: '754347097', found: '-743032134'
Test #6:
score: 0
Wrong Answer
time: 1571ms
memory: 18208kb
input:
100000 100000 14736 16956 19864 23894 29403 5507 12182 6188 17192 14440 18618 3970 15396 15037 23334...
output:
17008 73008 935797904 16519312 15383 25232 646921889 75334 25854 46510 797344028 517157465 595936107...
result:
wrong answer 7th lines differ - expected: '236856418', found: '646921889'
Test #7:
score: 0
Wrong Answer
time: 745ms
memory: 10220kb
input:
50000 50000 17799 29763 25337 21321 1391 31852 27418 28753 18524 14044 15976 18893 12274 22834 11348...
output:
19498 688600123 -515507127 -136500464 755663499 990634374 369627246 856849059 393870479 520009101 -6...
result:
wrong answer 2nd lines differ - expected: '473297203', found: '688600123'
Test #8:
score: 0
Wrong Answer
time: 1124ms
memory: 10220kb
input:
50000 50000 10654 14956 14287 25326 8102 30579 11682 23553 272 22672 14460 30241 13026 12738 4912 72...
output:
717018991 140916081 869990676 306496638 645808065 700834676 10388 4939 274390950 255787433 883873936...
result:
wrong answer 3rd lines differ - expected: '273712387', found: '869990676'
Test #9:
score: 0
Wrong Answer
time: 1621ms
memory: 18176kb
input:
90000 90000 29538 28214 24706 30393 27759 9002 13458 10243 15713 14881 10630 5593 7942 24578 29370 1...
output:
46041336 738703020 3888 402391875 37270 872563699 273399892 -257372076 70929994 -104693694 93280847 ...
result:
wrong answer 1st lines differ - expected: '738835738', found: '46041336'
Test #10:
score: 0
Wrong Answer
time: 1694ms
memory: 18248kb
input:
100000 100000 23515 49 31372 25112 16779 21279 30735 32743 14678 15189 1763 23114 32215 14873 20487 ...
output:
-571007943 375035849 562130727 662173102 678672360 605516093 -13529231 24257361 483381164 979056994 ...
result:
wrong answer 1st lines differ - expected: '576735050', found: '-571007943'