日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

The Brand New Function(CF-224C)

發布時間:2025/3/17 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 The Brand New Function(CF-224C) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Problem Description

Polycarpus has a sequence, consisting of n non-negative integers: a1,?a2,?...,?an.

Let's define function f(l,?r) (l,?r are integer, 1?≤?l?≤?r?≤?n) for sequence a as an operation of bitwise OR of all the sequence elements with indexes from l to r. Formally: f(l,?r)?=?al | al?+?1 | ... ?| ar.

Polycarpus took a piece of paper and wrote out the values of function f(l,?r) for all l,?r (l,?r are integer, 1?≤?l?≤?r?≤?n). Now he wants to know, how many distinct values he's got in the end.

Help Polycarpus, count the number of distinct values of function f(l,?r) for the given sequence a.

Expression x | y means applying the operation of bitwise OR to numbers x and y. This operation exists in all modern programming languages, for example, in language C++ and Java it is marked as "|", in Pascal — as "or".

Input

The first line contains integer n (1 ≤ n ≤ 105) — the number of elements of sequence a. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 106) — the elements of sequence a.

Output

Print a single integer — the number of distinct values of function f(l,?r) for the given sequence a.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.

Examples

Input

3
1 2 0

Output

4

Input

10
1 2 3 4 5 6 1 2 9 10

Output

11

題意:給出 n 個數,定義函數 F(l,r),表示區間 [l,r] 各項的 或 的和,問 F(l,r) 有多少個不同的值

思路:使用 set,兩重循環枚舉,然后由于所有位都為 1 的數與其他數運算是這個數自身,剪枝剪掉即可

Source Program

#include<iostream> #include<cstdio> #include<cstdlib> #include<string> #include<cstring> #include<cmath> #include<ctime> #include<algorithm> #include<utility> #include<stack> #include<queue> #include<vector> #include<set> #include<map> #include<bitset> #define EPS 1e-9 #define PI acos(-1.0) #define INF 0x3f3f3f3f #define LL long long const int MOD = 1E9+9; const int N = 1000000+5; const int dx[] = {-1,1,0,0,-1,-1,1,1}; const int dy[] = {0,0,-1,1,-1,1,-1,1}; using namespace std;int a[N]; set<int> st; int main() {int n;scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&a[i]);for(int i=1;i<=n;i++){int x=a[i];int y=0;st.insert(x);for(int j=i+1;j<=n;j++){x|=a[j];y|=a[j];st.insert(x);if(x==y)//剪枝break;}}printf("%d\n",st.size());return 0; }

?

總結

以上是生活随笔為你收集整理的The Brand New Function(CF-224C)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 伊人久操| 久久婷五月 | 奇米精品一区二区三区在线观看 | 亚洲欧洲在线观看 | 国产天堂av在线 | 美女张开腿流出白浆 | 午夜福利电影 | 动漫精品一区一码二码三码四码 | 欧美成人三级 | 日韩欧美一级片 | 超碰在| a视频在线免费观看 | 国产精品嫩草69影院 | 免费裸体美女网站 | 婷婷导航 | 99在线观看免费视频 | 在线看黄色网址 | 日韩岛国片 | 什么网站可以看毛片 | 伦理自拍 | 国产又粗又黄又爽又硬的视频 | 国产成年无码久久久久毛片 | xxx日韩| 天天操天天干天天干 | 国产欧美久久久久久 | 在线中文字幕播放 | 国产一级片中文字幕 | 肌肉猛男裸体gay网站免费 | 伊人久久大香线蕉av色婷婷色 | 中文精品无码中文字幕无码专区 | 久久精品色欲国产AV一区二区 | 中文字幕人成乱码熟女香港 | 国产一区二区在线免费观看 | 亚洲福利视频一区 | 伊人av在线 | 久久精品国产亚洲av麻豆蜜芽 | 手机福利在线 | 久久久久蜜桃 | 亚洲女同志亚洲女同女播放 | 久久国产精品精品国产色婷婷 | 538国产精品一区二区免费视频 | 69视频在线 | 91久久国产精品 | 色香色香欲天天天影视综合网 | 国产精品区在线 | 贝利弗山的秘密1985版免费观看 | 奇米精品一区二区三区在线观看一 | 亚洲视频成人 | 国产人与禽zoz0性伦 | 欧美系列一区二区 | 午夜av网| 亚洲视频导航 | 粉嫩av | 成人午夜视频在线观看 | 国产欧美在线精品日韩 | 快播在线视频 | 午夜精品久久久久久久久 | av免费播放 | 丰满少妇av | 网站av在线 | jizz性欧美15| 亚洲欧美一区二区精品久久久 | 稀缺呦国内精品呦 | 久草中文在线观看 | 免费观看av毛片 | 朝鲜一级黄色片 | 黄免费在线观看 | 久久综合国产 | 欧美日韩精品在线观看视频 | 筱田优av| 欧美xxxxhd | 亚洲一区二区在线电影 | 婷婷啪啪 | 日批视频网站 | 97精品久久 | 日韩久久一区二区 | 美女丝袜av| 久久在线中文字幕 | 亚洲第一福利网站 | 五月婷婷天堂 | 影音先锋男人站 | 成人免费av网站 | 免费观看美女裸体网站 | 午夜神马福利 | 成人五区 | 乱人伦av| av免费在线观看网站 | 亚洲精品lv| 国产精品天美传媒 | 综合天堂av久久久久久久 | 91天天色| 在线播放av网站 | 人人澡人人澡人人澡 | 亚洲国产aⅴ成人精品无吗 日韩乱论 | 国产精品一区二区在线免费观看 | 欧美一区二区福利视频 | 欧美视频第一页 | 日本美女逼 | 国产 一二三四五六 |