【题目分析】

这题貌似在UVA上做过,高精度高斯消元。

练习赛T2,然后突然脑洞出来一个用Bitset的方法。

发现代码只需要30多行就A掉了

Bitset大法好

【代码】

#include <cstdio>
#include <bitset>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define F(i,j,k) for (int i=j;i<=k;++i)
#define D(i,j,k) for (int i=j;i>=k;--i)
#define ll long long
#define maxn 2005
const int md=1000000007;
int pr[maxn],ispr[maxn],top=0;
bitset <505> lb[505],now;
int main()
{
F(i,2,maxn-1)
{
if (!ispr[i]) pr[++top]=i;
for (int j=1;j<=top&&pr[j]*i<maxn;++j)
{
if (i%pr[j]==0) {ispr[i*pr[j]]=1; break;}
ispr[i*pr[j]]=1;
}
}
int t,n,cnt;ll x;
scanf("%d",&t);
int kas=0;
while (t--)
{
printf("Case #%d:\n",++kas);
cnt=0;
F(i,0,504) lb[i].reset();
scanf("%d",&n);
F(i,1,n)
{
scanf("%lld",&x);
now.reset();
F(i,1,top)
{
int flag=0;
while (x%pr[i]==0) x/=pr[i],flag^=1;
now[i]=flag;
}
int tag=1;
D(j,500,1)
if (now[j])
{
if (lb[j].count()==0) {lb[j]=now;tag=0;break;}
else now^=lb[j];
}
cnt+=tag;
}
ll ans=1;
while (cnt)
{
ans<<=1;
ans%=md;
cnt--;
}
printf("%lld\n",(ans-1+md)%md);
}
}

  

HDU 5833 Zhu and 772002 ——线性基的更多相关文章

  1. hdu 5833 Zhu and 772002 ccpc网络赛 高斯消元法

    传送门:hdu 5833 Zhu and 772002 题意:给n个数,每个数的素数因子不大于2000,让你从其中选则大于等于1个数相乘之后的结果为完全平方数 思路: 小于等于2000的素数一共也只有 ...

  2. HDU 5833 Zhu and 772002

    HDU 5833 Zhu and 772002 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/ ...

  3. HDU 5833 Zhu and 772002 (高斯消元)

    Zhu and 772002 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5833 Description Zhu and 772002 are b ...

  4. hdu 5833 Zhu and 772002 高斯消元

    Zhu and 772002 Problem Description Zhu and 772002 are both good at math. One day, Zhu wants to test ...

  5. HDU 5833 Zhu and 772002(高斯消元)

    题意:给n个数,从n个数中抽取x(x>=1)个数,这x个数相乘为完全平方数,求一共有多少种取法,结果模1000000007. 思路:每个数可以拆成素数相乘的形式,例如: x1 2=2^1 * 3 ...

  6. HDU 5833 Zhu and 772002 (数论+高斯消元)

    题目链接 题意:给定n个数,这n个数的素因子值不超过2000,从中取任意个数使其乘积为完全平方数,问有多少种取法. 题解:开始用素筛枚举写了半天TLE了,后来队友说高斯消元才想起来,果断用模板.赛后又 ...

  7. hdu 5833 Zhu and 772002 异或方程组高斯消元

    ccpc网赛卡住的一道题 蓝书上的原题 但是当时没看过蓝书 今天又找出来看看 其实也不是特别懂 但比以前是了解了一点了 主要还是要想到构造异或方程组 异或方程组的消元只需要xor就好搞了 数学真的是硬 ...

  8. HDU - 5833: Zhu and 772002 (高斯消元-自由元)

    pro:给定N个数Xi(Xi<1e18),保证每个数的素因子小于2e3:问有多少种方案,选处一些数,使得数的乘积是完全平方数.求答案%1e9+7: N<300; sol:小于2e3的素数只 ...

  9. 【HDU 3949】 XOR (线性基,高斯消元)

    XOR Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

随机推荐

  1. Java 语言中一个字符占几个字节?

    Java中理论说是一个字符(汉字 字母)占用两个字节. 但是在UTF-8的时候 new String("字").getBytes().length 返回的是3 表示3个字节 作者: ...

  2. iOS:让UIView覆盖导航栏

    当我们想做一个弹出式菜单时,想将导航栏也一起盖住不显示的话,可以用如下语句实现: UIView* myView = /* 你自定义的view */; UIWindow* currentWindow = ...

  3. Nginx性能优化参考

    nginx性能优化参考 1)调整配置文件中的配置项的值(配置文件:nginx.conf) worker_processes auto;开启的进程数,一般配置为跟逻辑CPU核数一样worker_rlim ...

  4. SQL 转换函数

    1.字符串与字符串相加 字符串相加   得到的是拼接成一列的字符串类型 例如 select name+code from car       name是nvarchar  code也是nvarchar ...

  5. COGS 1427. zwei

    ★☆   输入文件:zwei.in   输出文件:zwei.out   简单对比时间限制:1 s   内存限制:256 MB ‘‘ [样例输入] 5 5 1 2 3 4 5 1 1 3 1 3 5 0 ...

  6. haml scss转换编写html css的前期工作

    http://www.w3cplus.com/sassguide/install.html 先下载ruby $ gem sources $ gem sources --remove https://r ...

  7. tensorflowjs下载源文件到本地不能加载模型解决方案

    大多数情况(非源文件错误)下载源文件到本地不能加载模型,那么你可能需要搭建一个本地WEB服务器. 1.安装apache或ngnix,可以参照这个博客 2.强烈推荐一个Chrome插件Web Serve ...

  8. 用cssText批量修改样式

    一般情况下我们用js设置元素对象的样式会使用这样的形式: var element= document.getElementById(“id”);element.style.width=”20px”;e ...

  9. Android 使用 adb命令 远程安装apk

    Android 使用 adb命令 远程安装apk ./adb devices 列出所有设备 ./adb connect 192.168.1.89 连接到该设备 ./adb logcat 启动logca ...

  10. House of force

    0x00 利用要点 1.申请一块非常大的块. 2.精心构造size覆盖top chunk的chunk header. 3.调用malloc()实现任意地址写 0x01 申请一块非常大的块. 申请一个负 ...