CodeForces 243A|The Brand New Function|位运算
来源:互联网 发布:wireshark软件下载 编辑:程序博客网 时间:2024/06/06 17:19
A. The Brand New Function
题目大意
Polycarpus有一个由n个非负整数组成的序列。
我们定义函数
Polycarpus在纸上写下了所有的
输入
第一行1个整数
第二行n个整数,表示序列各项元素
输出
输出
样例
input
3
1 2 0
output
4
input
10
1 2 3 4 5 6 1 2 9 10
output
11
Note
第一个样例中:6个
代码
#include <cstdio>#include <cstring>#include <cstdlib>#include <algorithm>#include <vector>#include <list>#include <map>#include <set>#include <queue>#include <functional>#include <utility>typedef long long ll;const int inf = 0x7ffffff;#define FILENAME "or"#define FOR(i,j,k) for(i=j;i<=k;++i)#define rep(i,j,k) for(i=j;i<k;++i)#define mem(i,j) memset(i,j,sizeof(i))#define forEach(i,j) for(typeof(j.begin()) i=j.begin();i!=j.end();++i)int read() { int f = 1, s = 0; char ch = getchar(); for ( ; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1; for ( ; '0' <= ch && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0'; return s * f;}namespace Solve { const int N = 100005; int mark[1<<20], a[N]; void solve() { int n = read(), i, x, y, j, ans = 0; FOR(i,1,n) a[i] = read(); FOR(i,1,n) { x = 0; if (!mark[a[i]]) mark[a[i]] = 1, ++ans; for (j = i - 1; j; --j) { x |= a[j]; if (!mark[x | a[i]]) mark[x | a[i]] = 1, ++ans; if ((x | a[i]) == x) break; } } printf("%d", ans); }}int main() { freopen(FILENAME".in","r",stdin); freopen(FILENAME".out","w",stdout); Solve::solve(); return 0;}
阅读全文
0 0
- CodeForces 243A|The Brand New Function|位运算
- Codeforces Round #150 (Div. 1) A. The Brand New Function
- Codeforces Round #150 (Div. 2) C. The Brand New Function
- CF The Brand New Function
- CF 244 C. The Brand New Function 思维(二进制,区间或运算不同结果)
- 状态压缩DP codeforces 244 Problem C. The Brand New Function 和 codeforces 165 E. Compatible Numbers
- a brand new day ~
- A Brand New World
- A brand new day
- A Brand New Begining
- 1 The Brand New Stuff
- a brand of new knew
- CodeForces 202B Brand New Easy Problem
- codeforces 202B Brand New Easy Problem
- 2015-2-7 A Brand-New Begining
- Codeforces--631A--Interview(位运算)
- CodeForces 631A:Interview【位运算】
- codeforces-618A-Slime Combining【位运算】
- 【Gerrit】Gerrit cmd query (gerrit命令行查询change信息)
- 【python】jiraAPI使用教程 自动创建jira问题单并置状态为OPEN
- 通过页面调用APP【H5与APP互通】
- 【python】Redis介绍及简单使用
- 使用的DockPanel的心得
- CodeForces 243A|The Brand New Function|位运算
- 【python】PIL 批量绘制图片矩形框工具
- 【python】pandas & matplotlib 数据处理 绘制曲面图
- 【Django】Django web项目部署(Nginx+uwsgi)
- 【Django】Django 定时任务实现(django-crontab+command)
- 【WEB前端】使用百度ECharts,绘制项目质量报表
- 【WEB前端】CSS常用选择器
- 【WEB前端】CSS继承性和层叠性(极度重要)
- svn管理:TotoiseSVN的基本使用方法