CF243A.The Brand New Function

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Polycarpus has a sequence, consisting of nn non-negative integers: a1,a2,...,ana_{1},a_{2},...,a_{n} .

Let's define function f(l,r)f(l,r) ( l,rl,r are integer, 1<=l<=r<=n1<=l<=r<=n ) for sequence aa as an operation of bitwise OR of all the sequence elements with indexes from ll to rr . Formally: f(l,r)=al  al+1  ...   arf(l,r)=a_{l} | a_{l+1} | ...\  | a_{r} .

Polycarpus took a piece of paper and wrote out the values of function f(l,r)f(l,r) for all l,rl,r ( l,rl,r are integer, 1<=l<=r<=n1<=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)f(l,r) for the given sequence aa .

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

输入格式

The first line contains integer nn (1<=n<=105)(1<=n<=10^{5}) — the number of elements of sequence aa . The second line contains nn space-separated integers a1,a2,...,ana_{1},a_{2},...,a_{n} (0<=ai<=106)(0<=a_{i}<=10^{6}) — the elements of sequence aa .

输出格式

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

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.

输入输出样例

  • 输入#1

    3
    1 2 0
    

    输出#1

    4
  • 输入#2

    10
    1 2 3 4 5 6 1 2 9 10
    

    输出#2

    11

说明/提示

In the first test case Polycarpus will have 6 numbers written on the paper: f(1,1)=1f(1,1)=1 , f(1,2)=3f(1,2)=3 , f(1,3)=3f(1,3)=3 , f(2,2)=2f(2,2)=2 , f(2,3)=2f(2,3)=2 , f(3,3)=0f(3,3)=0 . There are exactly 44 distinct numbers among them: 0,1,2,30,1,2,3 .

首页