mirror of
https://gitcode.com/Zengtudor/alg2025.git
synced 2025-12-16 12:13:03 +00:00
feat: 添加子集和计算功能
实现通过位运算计算子集和并统计出现次数
This commit is contained in:
parent
71bb5fe79f
commit
f6d958f00a
@ -2,10 +2,12 @@
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <istream>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
using ll = int64_t;
|
||||
|
||||
ll n,b;
|
||||
ll n,b,ans;
|
||||
struct P{
|
||||
ll x,y;
|
||||
inline bool operator<(const P&o)const{
|
||||
@ -16,6 +18,7 @@ struct P{
|
||||
}
|
||||
}g;
|
||||
std::vector<P> a;
|
||||
std::unordered_map<ll,std::unordered_map<ll,ll>> m;
|
||||
|
||||
int main(){
|
||||
std::iostream::sync_with_stdio(false);
|
||||
@ -36,6 +39,17 @@ int main(){
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
b=(n+1)/2;
|
||||
|
||||
b=n/2+1;
|
||||
for(ll tmp=1;tmp<(1ull<<(b-1));tmp++){
|
||||
ll ax=0,ay=0;
|
||||
for(ll j=0;j<b-1;j++){
|
||||
if(tmp&(1ll<<j)){
|
||||
const ll nj=j+1;
|
||||
ax+=a[nj].x;
|
||||
ay+=a[nj].y;
|
||||
}
|
||||
}
|
||||
m[ax][ay]++;
|
||||
}
|
||||
// for(ll msk=1;msk<(1ull<<(n-b)))
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user