P3773 [CTSC2017]吉夫特 题解
\(……\)
腿疼,打字没力气,放代码就咕了
感谢神仙 $wsy $ _ $ jim$ 提供思路
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
#include<chrono>
#include<random>
#include<unordered_map>
#define ll long long
#define ull unsigned long long
#define rll register long long
#define ri register int
using namespace std;
const int N=300010,MOD=1000000007;
int n,ans;
int a[N],f[N];
inline ll read(){
ll x=0,y=1;
char c=getchar();
while (c<'0'||c>'9'){
if(c=='-')
y=-1;
c=getchar();
}
while(c>='0'&&c<='9'){
x=x*10+c-'0';
c=getchar();
}
return x*y;
}
int main(){
n=read();
for(int i=1;i<=n;i++)
a[i]=read();
for(int i=1;i<=n;i++){
for(int j=a[i]&(a[i]-1);j;j=a[i]&(j-1))//这是我没有想到的\kk
f[j]=(f[j]+f[a[i]]+1)%MOD;
ans=(ans+f[a[i]])%MOD;
}
printf("%d",ans);
return 0;
}