51Nod1674[区间的价值 V2]--分块
来源:互联网 发布:无主之地2怎么连接网络 编辑:程序博客网 时间:2024/06/04 00:58
【链接】
51nod1674
【解题报告】
经典的分块题目。
因为对于一组数
#include<cstdio>#define LL long longusing namespace std;const int maxn=100005,maxv=65,tt=1000000007;int n,tot,ans,a[maxn];struct wjd{ int a,b,l;}c[maxn];inline char nc(){ static char buf[100000],*l=buf,*r=buf; if (l==r) r=(l=buf)+fread(buf,1,100000,stdin); if (l==r) return EOF; return *l++;}inline int Read(){ int res=0; char ch=nc(); while (ch<'0'||ch>'9') ch=nc(); while (ch>='0'&&ch<='9') res=(res<<3)+(res<<1)+ch-48,ch=nc(); return res;}void Updata(int x){ c[++tot]=(wjd){a[x],a[x],1}; for (int i=1; i<=tot; i++) c[i].a&=a[x],c[i].b|=a[x]; int now=tot; tot=1; for (int i=2; i<=now; i++) if (c[i].a==c[tot].a&&c[i].b==c[tot].b) c[tot].l+=c[i].l; else c[++tot]=c[i]; for (int i=1; i<=tot; i++) ans=(ans+(LL)c[i].a*c[i].b%tt*c[i].l%tt)%tt;}int main(){ freopen("1674.in","r",stdin); freopen("1674.out","w",stdout); n=Read(); ans=tot=0; for (int i=1; i<=n; i++) a[i]=Read(); for (int i=n; i; i--) Updata(i); printf("%d\n",ans); return 0;}
阅读全文
1 0
- 51Nod1674[区间的价值 V2]--分块
- 【and or分块】51Nod1674[区间的价值 V2]题解
- 区间的价值 V2
- 51NOD AGT19A 区间的价值 V2
- 51NOD 1674 区间的价值 V2
- 51NOD-1674 区间的价值 V2
- 51nod 区间的价值 V2
- 51Nod-1674-区间的价值 V2
- 51nod 1674 区间的价值 V2
- 51nod 1674 区间的价值 V2
- 【51nod 算法马拉松19 A】区间的价值 V2
- 51nod 1564 && 1674 区间的价值(V2) 数列分治
- 51Nod 1674——区间的价值 V2
- 【51nod】1674 区间的价值 V2 状态压缩
- 【数学结论】51Nod 1674 区间的价值 V2
- 51nod 1674 区间的价值 V2(暴力)
- 51nod 1674 区间的价值 V2(分治)
- 【51NOD 1674】【51NOD 算法马拉松19】区间的价值 V2
- ubuntu安装迅雷
- android搭建开发环境 ---- gradle wrapper出现问题
- Opencv HighGUI函数_窗口
- 关于如何在WPS中生成附图索引
- 网易2017年校招题
- 51Nod1674[区间的价值 V2]--分块
- 第一篇博客
- SQL基础语句【转帖】
- [转]如何使用CSDN-markdown编辑器
- 视频结构化综述
- 正则表达式笔记
- Deep Learning in OpenCV
- Network POJ
- ThinkPHP5.0 集成邮件服务--PHPMailer