问题是这样
有一个二分图,i 与i xor x 相连 求交叉数
考试是时间太赶没去想(T_T)
其实这题枚举的是a和b不同的最高位(Xor后 变的那位)
1 \ / 1
0 / \ 0
最高位长这样
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
#define F (1000000007)
#define MAXN (100+10)
#define For(i,n) for(int i=1;i<=n;i++)
#define LL long long
long long ans=0;
char s[MAXN];
long long sqr(long long a){return a*a%F;}
long long bin[1000];
int main()
{
scanf("%s",s+1);
int n=strlen(s+1);
bin[0]=1;For(i,999) bin[i]=(bin[i-1]*2)%F;
For(i,n) if (s[i]=='1') ans=(ans+(bin[i-1])%F*sqr(bin[n-i]))%F;
cout<<ans<<endl;
return 0;
}
本文介绍了一种计算二分图中交叉配对复杂度的方法,通过枚举不同最高位来计算给定二分图中 Malek Dance Club 成员与 Natalia Fan Club 成员之间的交叉配对数量。
from
NFC. Your task is to calculate the complexity of this assignment modulo
denotes
applying «XOR» to numbers
762

被折叠的 条评论
为什么被折叠?



