标签:i++ algorithm cst logs blog style printf turn pac
ST表模板题目
#include <cstdio> #include <cmath> #include <algorithm> using namespace std; int n,m,Maxsum[200005][20]; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&Maxsum[i][0]); } int fuck = log(n) / log(2); for(int j=1;j<=fuck;j++) for(int i=1;i<=n;i++) if(i+(1<<j)-1 <= n){ Maxsum[i][j] = max(Maxsum[i][j-1],Maxsum[i+(1<<(j-1))][j-1]); } scanf("%d",&m); while(m--){ int x,y; scanf("%d%d",&x,&y); fuck = log(y-x+1) / log(2); printf("%d\n",max(Maxsum[x][fuck],Maxsum[y-(1<<fuck)+1][fuck])); } return 0; }
标签:i++ algorithm cst logs blog style printf turn pac
原文地址:http://www.cnblogs.com/OIerLYF/p/7040912.html