this is a sad thing
//本文置顶,希望不要再有contest的总结和它争位置
淋了点雨,头有点疼,中午罚自己没吃饭, 他说要化悲愤为食欲,可是我就是吃不下去。
还记得以前的时候,为了节约时间,一起跑去超市买个面包,然后再跑回来的事,结果两个人时间没节约多少,反而都病了,于是就要喝药。
TA现在很优秀。。。
喜欢那时候的自己,可能有很多不好,很多人不理解,但是,嗯,就这样。
老王发现的一个bug
T1Analyse:暴力能过的题。。。
其实灰常灰常的简单,不过。。。
1 #include<bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int n; 6 cin>>n; 7 bool flag=true; 8 int a=n%10,b=n/10%10,c=n/100%10; 9 int d=n/1000%10,e=n/10000%10,f=n/100000%10; 10 while(flag) 11 { 12 a++; 13 if(a==10){ 14 a=0;b++; 15 } 16 if(b==10){ 17 b=0;c++; 18 } 19 if(c==10){ 20 c=0;d++; 21 } 22 if(d==10){ 23 d=0;e++; 24 } 25 if(e==10){ 26 e=0;f++; 27 } 28 if(a+10*b+100*c+1000*d+10000*e+100000*f>999999){ 29 flag=false; 30 break; 31 } 32 if(a+b+c==d+e+f)break; 33 } 34 if(flag)cout<<a+10*b+100*c+1000*d+10000*e+100000*f; 35 else cout<<"-1"; 36 return 0; 37 }
T2
Analyse:
(老师的原话欸,不要问我想说明什么,我也不知道)
考试的时候没有人AC掉这题(当然有几位大佬就差一点点 一点点~~~)
暴力的做法:(我就是打暴力,but。。。输出符弄错了-0.0-,于是输出了一些很恶心的东西,我不得不告诉你我暴力打的好像是对的,嗯嗯,就是对的)
辗转相除求最大公约数,其他的都是浮云。
inline int gcd(int m,int n) { return m%n==0?n:gcd(n,m%n); }
优秀的正解:
对于A和B,我们计算出fA[i]=true表示A数组中存在某个数是i的倍数;fB[i]=true表示B数组中存在某个数是i的倍数,最后从小到大枚举i,如果fA[i]=fB[i]=true,就说明i是最大的gcd!
怎样找到gcd最大的那对数的最大sum呢?
1、搞个数组MaxA[]和MaxB[],代表数组中所有是i倍数的数中最大的数;
找到gcd后,输出MaxA[gcd]+MaxB[gcd];
2、找到gcd后,直接O(n)循环一遍,找出各数组中是gcd倍数的最大的数;
T3
Analyse: 二分基础题?:表示没学过二分。
不过思路是有的,然而编译器坏掉了,可能是因为那个恶心的输出问题(要哭了-0...0-)。
还是不太会码代码吧,其实说真心话,这些题思路上没有难到想不上去,但是就是不会码,码完之后调试就把我给弄疯了(啊,我这暴脾气),我只是一个学编程一个半月的小蒟蒻~~~我还是太弱了啦,码代码功底不够深呐。真正要我码题的时候我又不耐烦,而且码得很慢,以为思路清楚就好(这种题还有谁的思路不清楚吗)于是态度很不端正。
给了两种方法~~
第一种方法:按照价格排序,预处理出每个宝贝之前每种品牌有多少个。
code1
int get(int x) { int ret=0; for(int i=1;i<=m;i++) { if(b[i]==1) ret+=s1[x]; if(b[i]==2) ret+=s2[x]; if(b[i]==3) ret+=s3[x]; if(b[i]==4) ret+=s4[x]; if(b[i]==5) ret+=s5[x]; } return ret; }
code2
scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i].num); for(int i=1;i<=n;i++) scanf("%d",&a[i].cost); sort(a+1,a+1+n,cmp); for(int i=1;i<=n;i++) { if(a[i].num==1)s1[i]=s1[i-1]+1; else s1[i]=s1[i-1]; if(a[i].num==2)s2[i]=s2[i-1]+1; else s2[i]=s2[i-1]; if(a[i].num==3)s3[i]=s3[i-1]+1; else s3[i]=s3[i-1]; if(a[i].num==4)s4[i]=s4[i-1]+1; else s4[i]=s4[i-1]; if(a[i].num==5)s5[i]=s5[i-1]+1; else s5[i]=s5[i-1]; } scanf("%d",&q); while(q--) { scanf("%d",&m); for(int i=1;i<=m;i++) scanf("%d",&b[i]); scanf("%d",&k); if(get(n)<k) { cout<<"-1"<<endl; continue; } l=1,r=n; while(l<=r) { mid=(l+r)>>1; if(get(mid)>=k) r=mid-1; else l=mid+1; } cout<<a[l].cost<<endl; }
第二种就有很多不怕麻烦的大佬在用了,真的是不怕麻烦,我怕麻烦,所以我拿不到分。
上code
#include <bits/stdc++.h> using namespace std; typedef long long ll; int read(void) { int sign=1,num=0; char c=getchar(); for(;c<‘0‘||c>‘9‘;c=getchar()) if(c==‘-‘) sign=-1; for(;c>=‘0‘&&c<=‘9‘;c=getchar()) num=(num<<1)+(num<<3)+c-48; return num*sign; } int n,q,ip1,ip2,ip[10],ans; ll b1[100050]; int lenb1=0; ll b2[100050]; int lenb2=0; ll b3[100050]; int lenb3=0; ll b4[100050]; int lenb4=0; ll b5[100050]; int lenb5=0; ll b1b2[100050]; int lenb1b2=0; ll b1b3[100050]; int lenb1b3=0; ll b1b4[100050]; int lenb1b4=0; ll b1b5[100050]; int lenb1b5=0; ll b2b3[100050]; int lenb2b3=0; ll b2b4[100050]; int lenb2b4=0; ll b2b5[100050]; int lenb2b5=0; ll b3b4[100050]; int lenb3b4=0; ll b3b5[100050]; int lenb3b5=0; ll b4b5[100050]; int lenb4b5=0; ll b1b2b3[100050]; int lenb1b2b3=0; ll b1b2b4[100050]; int lenb1b2b4=0; ll b1b2b5[100050]; int lenb1b2b5=0; ll b1b3b4[100050]; int lenb1b3b4=0; ll b1b3b5[100050]; int lenb1b3b5=0; ll b1b4b5[100050]; int lenb1b4b5=0; ll b2b3b4[100050]; int lenb2b3b4=0; ll b2b3b5[100050]; int lenb2b3b5=0; ll b2b4b5[100050]; int lenb2b4b5=0; ll b3b4b5[100050]; int lenb3b4b5=0; ll b1b2b3b4[100050]; int lenb1b2b3b4=0; ll b1b2b3b5[100050]; int lenb1b2b3b5=0; ll b1b2b4b5[100050]; int lenb1b2b4b5=0; ll b1b3b4b5[100050]; int lenb1b3b4b5=0; ll b2b3b4b5[100050]; int lenb2b3b4b5=0; struct node { ll price,brand; }thing[100050]; bool mycmp(node x,node y) { return x.price<y.price; } void out(void) { switch(ip1) { case 1:{ if(ip[1]==1) ans=(lenb1>=ip2?b1[ip2]:-1); else if(ip[1]==2) ans=(lenb2>=ip2?b2[ip2]:-1); else if(ip[1]==3) ans=(lenb3>=ip2?b3[ip2]:-1); else if(ip[1]==4) ans=(lenb4>=ip2?b4[ip2]:-1); if(ip[1]==5) ans=(lenb5>=ip2?b5[ip2]:-1); break; } case 2:{ if(ip[1]==1&&ip[2]==2) ans=(lenb1b2>=ip2?b1b2[ip2]:-1); else if(ip[1]==1&&ip[2]==3) ans=(lenb1b3>=ip2?b1b3[ip2]:-1); else if(ip[1]==1&&ip[2]==4) ans=(lenb1b4>=ip2?b1b4[ip2]:-1); else if(ip[1]==1&&ip[2]==5) ans=(lenb1b5>=ip2?b1b5[ip2]:-1); else if(ip[1]==2&&ip[2]==3) ans=(lenb2b3>=ip2?b2b3[ip2]:-1); else if(ip[1]==2&&ip[2]==4) ans=(lenb2b4>=ip2?b2b4[ip2]:-1); else if(ip[1]==2&&ip[2]==5) ans=(lenb2b5>=ip2?b2b5[ip2]:-1); else if(ip[1]==3&&ip[2]==4) ans=(lenb3b4>=ip2?b3b4[ip2]:-1); else if(ip[1]==3&&ip[2]==5) ans=(lenb3b5>=ip2?b3b5[ip2]:-1); else if(ip[1]==4&&ip[2]==5) ans=(lenb4b5>=ip2?b4b5[ip2]:-1); break; } case 3:{ if(ip[1]==1&&ip[2]==2&&ip[3]==3) ans=(lenb1b2b3>=ip2?b1b2b3[ip2]:-1); else if(ip[1]==1&&ip[2]==2&&ip[3]==4) ans=(lenb1b2b4>=ip2?b1b2b4[ip2]:-1); else if(ip[1]==1&&ip[2]==2&&ip[3]==5) ans=(lenb1b2b5>=ip2?b1b2b5[ip2]:-1); else if(ip[1]==1&&ip[2]==3&&ip[3]==4) ans=(lenb1b3b4>=ip2?b1b3b4[ip2]:-1); else if(ip[1]==1&&ip[2]==3&&ip[3]==5) ans=(lenb1b3b5>=ip2?b1b3b5[ip2]:-1); else if(ip[1]==1&&ip[2]==4&&ip[3]==5) ans=(lenb1b4b5>=ip2?b1b4b5[ip2]:-1); else if(ip[1]==2&&ip[2]==3&&ip[3]==4) ans=(lenb2b3b4>=ip2?b2b3b4[ip2]:-1); else if(ip[1]==2&&ip[2]==3&&ip[3]==5) ans=(lenb2b3b5>=ip2?b2b3b5[ip2]:-1); else if(ip[1]==2&&ip[2]==4&&ip[3]==5) ans=(lenb2b4b5>=ip2?b2b4b5[ip2]:-1); else if(ip[1]==3&&ip[2]==4&&ip[3]==5) ans=(lenb3b4b5>=ip2?b3b4b5[ip2]:-1); break; } case 4:{ if(ip[1]==1&&ip[2]==2&&ip[3]==3&&ip[4]==4) ans=(lenb1b2b3b4>=ip2?b1b2b3b4[ip2]:-1); if(ip[1]==1&&ip[2]==2&&ip[3]==3&&ip[4]==5) ans=(lenb1b2b3b5>=ip2?b1b2b3b5[ip2]:-1); if(ip[1]==1&&ip[2]==3&&ip[3]==4&&ip[4]==5) ans=(lenb1b3b4b5>=ip2?b1b3b4b5[ip2]:-1); if(ip[1]==1&&ip[2]==2&&ip[3]==4&&ip[4]==5) ans=(lenb1b2b4b5>=ip2?b1b2b4b5[ip2]:-1); if(ip[1]==2&&ip[2]==3&&ip[3]==4&&ip[4]==5) ans=(lenb2b3b4b5>=ip2?b2b3b4b5[ip2]:-1); break; } case 5:{ ans=(n>=ip2?thing[ip2].price:-1); break; } } } int main() { n=read(); for (int i=1;i<=n;i++) thing[i].brand=read(); for (int j=1;j<=n;j++) thing[j].price=read(); sort(thing+1,thing+n+1,mycmp); for (int i=1;i<=n;i++) { switch(thing[i].brand) { case 1:{ b1[++lenb1]=thing[i].price; b1b2[++lenb1b2]=thing[i].price; b1b3[++lenb1b3]=thing[i].price; b1b4[++lenb1b4]=thing[i].price; b1b5[++lenb1b5]=thing[i].price; b1b2b3[++lenb1b2b3]=thing[i].price; b1b2b4[++lenb1b2b4]=thing[i].price; b1b2b5[++lenb1b2b5]=thing[i].price; b1b3b4[++lenb1b3b4]=thing[i].price; b1b3b5[++lenb1b3b5]=thing[i].price; b1b4b5[++lenb1b4b5]=thing[i].price; b1b2b3b4[++lenb1b2b3b4]=thing[i].price; b1b2b3b5[++lenb1b2b3b5]=thing[i].price; b1b3b4b5[++lenb1b3b4b5]=thing[i].price; b1b2b4b5[++lenb1b2b4b5]=thing[i].price; break; } case 2:{ b2[++lenb2]=thing[i].price; b1b2[++lenb1b2]=thing[i].price; b2b3[++lenb2b3]=thing[i].price; b2b4[++lenb2b4]=thing[i].price; b2b5[++lenb2b5]=thing[i].price; b1b2b3[++lenb1b2b3]=thing[i].price; b1b2b4[++lenb1b2b4]=thing[i].price; b1b2b5[++lenb1b2b5]=thing[i].price; b2b3b4[++lenb2b3b4]=thing[i].price; b2b3b5[++lenb2b3b5]=thing[i].price; b2b4b5[++lenb2b4b5]=thing[i].price; b1b2b3b4[++lenb1b2b3b4]=thing[i].price; b1b2b3b5[++lenb1b2b3b5]=thing[i].price; b2b3b4b5[++lenb2b3b4b5]=thing[i].price; b1b2b4b5[++lenb1b2b4b5]=thing[i].price; break; } case 3:{ b3[++lenb3]=thing[i].price; b2b3[++lenb2b3]=thing[i].price; b1b3[++lenb1b3]=thing[i].price; b3b4[++lenb3b4]=thing[i].price; b3b5[++lenb3b5]=thing[i].price; b1b2b3[++lenb1b2b3]=thing[i].price; b1b3b4[++lenb1b3b4]=thing[i].price; b1b3b5[++lenb1b3b5]=thing[i].price; b2b3b4[++lenb2b3b4]=thing[i].price; b2b3b5[++lenb2b3b5]=thing[i].price; b3b4b5[++lenb3b4b5]=thing[i].price; b1b2b3b4[++lenb1b2b3b4]=thing[i].price; b1b2b3b5[++lenb1b2b3b5]=thing[i].price; b1b3b4b5[++lenb1b3b4b5]=thing[i].price; b2b3b4b5[++lenb2b3b4b5]=thing[i].price; break; } case 4:{ b4[++lenb4]=thing[i].price; b2b4[++lenb2b4]=thing[i].price; b3b4[++lenb3b4]=thing[i].price; b1b4[++lenb1b4]=thing[i].price; b4b5[++lenb4b5]=thing[i].price; b1b3b4[++lenb1b3b4]=thing[i].price; b1b2b4[++lenb1b2b4]=thing[i].price; b1b4b5[++lenb1b4b5]=thing[i].price; b2b3b4[++lenb2b3b4]=thing[i].price; b2b4b5[++lenb2b4b5]=thing[i].price; b3b4b5[++lenb3b4b5]=thing[i].price; b1b2b3b4[++lenb1b2b3b4]=thing[i].price; b1b3b4b5[++lenb1b3b4b5]=thing[i].price; b2b3b4b5[++lenb2b3b4b5]=thing[i].price; b1b2b4b5[++lenb1b2b4b5]=thing[i].price; break; } case 5:{ b5[++lenb5]=thing[i].price; b2b5[++lenb2b5]=thing[i].price; b3b5[++lenb3b5]=thing[i].price; b1b5[++lenb1b5]=thing[i].price; b4b5[++lenb4b5]=thing[i].price; b1b3b5[++lenb1b3b5]=thing[i].price; b1b2b5[++lenb1b2b5]=thing[i].price; b1b4b5[++lenb1b4b5]=thing[i].price; b2b3b5[++lenb2b3b5]=thing[i].price; b2b4b5[++lenb2b4b5]=thing[i].price; b3b4b5[++lenb3b4b5]=thing[i].price; b1b2b3b5[++lenb1b2b3b5]=thing[i].price; b1b3b4b5[++lenb1b3b4b5]=thing[i].price; b2b3b4b5[++lenb2b3b4b5]=thing[i].price; b1b2b4b5[++lenb1b2b4b5]=thing[i].price; break; } } } q=read(); for (int i=1;i<=q;i++) { ip1=read(); for (int j=1;j<=ip1;j++) ip[j]=read(); sort(ip+1,ip+ip1+1); ip2=read(); out(); printf("%d\n",ans); } }
很恐怖(from 瓜皮)
其实有比上面那个看起来舒爽的代码,但是这个比较有气势,emmmmmm...
T4
Analyse:这是道dp题
1 #include<bits/stdc++.h> 2 using namespace std; 3 int n,m,k,ans; 4 int dp[400][400][400],x[400],y[400]; 5 void init() 6 { 7 scanf("%d%d%d",&n,&m,&k); 8 for(int i=1;i<=n;i++) 9 cin>>x[i]; 10 for(int j=1;j<=m;j++) 11 cin>>y[j]; 12 } 13 int solve(int l,int r,int k) 14 { 15 if(!k) return 0; 16 if(l<0|r<0) return 1e9; 17 if(dp[l][r][k]!=-1) 18 return dp[l][r][k]; 19 int cost=(x[l]-‘a‘)^(y[r]-‘a‘); 20 return dp[l][r][k]=min(cost+solve(l-1,r-1,k-1),min(solve(l-1,r,k),solve(l,r-1,k))); 21 } 22 //dp[i][j][p]表示A的前i个,B的前j个,LCS长度至少为p时,最少花的代价 23 int main() 24 { 25 init(); 26 ans=solve(n-1,m-1,k); 27 cout<<ans<<endl; 28 return 0; 29 }
假的
1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=350; 4 const int INF=1000000000; 5 int dis[26][26]={0}; 6 char a[N+1],b[N+1]; 7 int n,m,k; 8 int f[N+1][N+1]={0},dp[N+1][N+1]={0}; 9 int ans=INF; 10 int ri(){ 11 int x=0; 12 char c=getchar(); 13 for (;c<‘0‘||c>‘9‘;c=getchar()); 14 for (;c<=‘9‘&&c>=‘0‘;c=getchar()) x=(x<<1)+(x<<3)+c-‘0‘; 15 return x; 16 } 17 char rc(){ 18 char c=getchar(); 19 for (;c<‘a‘||c>‘z‘;c=getchar()); 20 return c; 21 } 22 inline void into(){ 23 for (int i=0;i<=25;i++) 24 for (int j=0;j<=25;j++) 25 dis[i][j]=i^j;//cost 26 scanf("%d%d%d",&n,&m,&k); 27 for (int i=1;i<=n;i++) 28 a[i]=rc();//读入优化 ,输入了x,y 29 for (int j=1;j<=m;j++) 30 b[j]=rc(); 31 } 32 inline void work(){ 33 for (int i=0;i<=n;i++) 34 for (int j=0;j<=m;j++) 35 f[i][j]=INF;//赋了一个很大很大的值 36 for (int t=1;t<=k;t++){//下面的这个循环要进行p次 37 for (int i=1;i<=n;i++) 38 for (int j=1;j<=m;j++){ 39 f[i][j]=min(f[i-1][j],f[i][j-1]); 40 if (a[i]==b[j])/**/ f[i][j]=min(f[i][j],dp[i-1][j-1]); 41 else f[i][j]=min(f[i][j],dp[i-1][j-1]+dis[a[i]-‘a‘][b[j]-‘a‘]); 42 } 43 for (int i=0;i<=n;i++) 44 for (int j=0;j<=m;j++) 45 dp[i][j]=f[i][j];//每次之后,都将f值赋给dp 46 } 47 } 48 inline void outo(){ 49 for (int i=1;i<=n;i++) 50 for (int j=1;j<=m;j++) 51 ans=min(ans,f[i][j]); 52 printf("%d\n",ans); 53 } 54 int main(){ 55 into(); 56 if (n<k||m<k) { 57 printf("-1\n"); 58 return 0; 59 } //不可能的情况 60 work(); 61 outo(); 62 return 0; 63 }
真的
T5
Analyse:种树(可惜我连播种都不熟,于是这两棵树就挂了,还有T6也是棵树)
//xw++,抄袭代码标注来源,%%%虚神 #include <bits/stdc++.h> using namespace std; /*为什么会有一个40,你会发现从40之后,阶乘都能被oo整除*/ #define ll long long const int N=1e6,P=1e9; int n,m,s; int a[N],t[N],b[41]; struct hh { int l,r,n[41],z; }tr[N];//神奇的定义,还可以这样数组struct ll v[41]; ll A; #define C getchar()-48 int read() { int s=0,t=1,k=C; for (;k<0||k>9;k=C) if (k==-3) t=-1; for (;k>=0&&k<=9;k=C) s=(s<<1)+(s<<3)+k; return s*t; } void fir() { v[1]=1; for (int i=1;++i<40;) v[i]=(v[i-1]*i)%P;//这个是在求阶乘吧。。。 } #define ls k<<1 #define rs k<<1|1 void bt(int k,int l,int r) { tr[k].l=l;tr[k].r=r; if (l==r) return; int M=l+r>>1; bt(ls,l,M);bt(rs,M+1,r); } void dow(int k) { int z=tr[k].z; if (!z) return; for (int i=40;--i;) { if (i+z<40) tr[ls].n[i+z]+=tr[ls].n[i], tr[rs].n[i+z]+=tr[rs].n[i]; tr[ls].n[i]=tr[rs].n[i]=0; } tr[ls].z+=z; tr[rs].z+=z; tr[k].z=0; } void ud(int k) { for (int i=40;--i;) tr[k].n[i]=tr[ls].n[i]+tr[rs].n[i]; } void cha1(int k,int l,int s) { if (l>tr[k].r||l<tr[k].l) return; if (tr[k].l==tr[k].r) { for (int i=40;--i;) tr[k].n[i]=0; if (s<40) tr[k].n[s]=1; return; } dow(k); cha1(ls,l,s); cha1(rs,l,s); ud(k); } void cha2(int k,int l,int r) { if (l>tr[k].r||r<tr[k].l) return; if (l<=tr[k].l&&tr[k].r<=r) { dow(k); for (int i=40;--i>=0;) tr[k].n[i+1]=tr[k].n[i]; ++tr[k].z; return; } dow(k); cha2(ls,l,r); cha2(rs,l,r); ud(k); } void que(int k,int l,int r) { if (l>tr[k].r||r<tr[k].l) return; if (l<=tr[k].l&&tr[k].r<=r) { for (int i=40;--i;) b[i]+=tr[k].n[i]; return; } dow(k); que(ls,l,r); que(rs,l,r); } int main() { fir(); cin>>n>>m; bt(1,1,n); for (int i=0;++i<=n;) { a[i]=read(); if (a[i]<40) cha1(1,i,a[i]); } while (m--) { int z=read(),x=read(),y=read(); if (z==1) { if (x>y) swap(x,y); cha2(1,x,y); } if (z==2) { A=0; memset(b,0,sizeof b); if (x>y) swap(x,y); que(1,x,y); for (int i=40;--i;) A=(A+v[i]*b[i]%P)%P; printf("%d\n",A); } if (z==3) cha1(1,x,y); } return 0; }
xw‘s
T6
原谅我直接抄代码了,表示不能理解
#include <bits/stdc++.h> using namespace std; #ifndef _WIN32 #define getchar getchar_unlocked #endif int get() { int n, c; while ((c = getchar()) < ‘0‘) { } n = c - ‘0‘; while ((c = getchar()) >= ‘0‘) { n = n * 10 + c - ‘0‘; } return n; } const int N = 100000; int ft[21][1 << 21]; int a[N]; int pw2[21]; // mod 2^i [0, 2^i) int add(int b, int x, int v) { for (; x < pw2[b]; x |= x + 1) { ft[b][x] += v; } } int sum(int b, int x) { int ret = 0; for (; x >= 0; x = (x & (x + 1)) - 1) { ret += ft[b][x]; } return ret; } int main() { int n, q; scanf("%d %d", &n, &q); pw2[0] = 1; for (int i = 0; i < 20; i++) { pw2[i + 1] = pw2[i] + pw2[i]; } for (int i = 0; i < n; i++) { int v = get(); a[i] = v; for (int j = 1; j < 21; j++) { add(j, v % pw2[j], 1); } } while (q--) { int op = get(), x = get(), y = get(); if (op == 1) { x--; for (int j = 1; j < 21; j++) { add(j, a[x] % pw2[j], -1); } a[x] = y; for (int j = 1; j < 21; j++) { add(j, y % pw2[j], 1); } } else { long long res = 0; for (int j = 1; j < 21; j++) { if (!(y & pw2[j - 1])) { continue; } int l = (pw2[j - 1] - x + pw2[20]) % pw2[j]; int r = (pw2[j] - x - 1 + pw2[20]) % pw2[j]; int t; if (l <= r) { t = sum(j, r) - sum(j, l - 1); } else { t = sum(j, pw2[j] - 1) + sum(j, r) - sum(j, l - 1); } res += (long long) t * pw2[j - 1]; } printf("%lld\n", res); } } return 0; }
chf‘s
那是个链接,可以去%谦虚的大佬
原文地址:https://www.cnblogs.com/ve-2021/p/9117615.html