HDU 5833 Zhu and 772002 ——线性基
【题目分析】
这题貌似在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 ——线性基的更多相关文章
- hdu 5833 Zhu and 772002 ccpc网络赛 高斯消元法
传送门:hdu 5833 Zhu and 772002 题意:给n个数,每个数的素数因子不大于2000,让你从其中选则大于等于1个数相乘之后的结果为完全平方数 思路: 小于等于2000的素数一共也只有 ...
- HDU 5833 Zhu and 772002
HDU 5833 Zhu and 772002 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/ ...
- HDU 5833 Zhu and 772002 (高斯消元)
Zhu and 772002 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5833 Description Zhu and 772002 are b ...
- hdu 5833 Zhu and 772002 高斯消元
Zhu and 772002 Problem Description Zhu and 772002 are both good at math. One day, Zhu wants to test ...
- HDU 5833 Zhu and 772002(高斯消元)
题意:给n个数,从n个数中抽取x(x>=1)个数,这x个数相乘为完全平方数,求一共有多少种取法,结果模1000000007. 思路:每个数可以拆成素数相乘的形式,例如: x1 2=2^1 * 3 ...
- HDU 5833 Zhu and 772002 (数论+高斯消元)
题目链接 题意:给定n个数,这n个数的素因子值不超过2000,从中取任意个数使其乘积为完全平方数,问有多少种取法. 题解:开始用素筛枚举写了半天TLE了,后来队友说高斯消元才想起来,果断用模板.赛后又 ...
- hdu 5833 Zhu and 772002 异或方程组高斯消元
ccpc网赛卡住的一道题 蓝书上的原题 但是当时没看过蓝书 今天又找出来看看 其实也不是特别懂 但比以前是了解了一点了 主要还是要想到构造异或方程组 异或方程组的消元只需要xor就好搞了 数学真的是硬 ...
- HDU - 5833: Zhu and 772002 (高斯消元-自由元)
pro:给定N个数Xi(Xi<1e18),保证每个数的素因子小于2e3:问有多少种方案,选处一些数,使得数的乘积是完全平方数.求答案%1e9+7: N<300; sol:小于2e3的素数只 ...
- 【HDU 3949】 XOR (线性基,高斯消元)
XOR Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
随机推荐
- 解决 FusionCharts3.2.1 首页无法载入的问题
在实际项目中测试FusionCharts3.2.1时,发现首次载入无法正常载入,第二次载入就恢复正常! 原因:FusionCharts ID与变量名重复 以下是正常写法: var member ...
- SQL 视图、事务
假设看多个不同的表 select *from student ,score,course,teacher 有重复的 改为select student.Sno,sname,ssex,sbirthd ...
- C# 语句 分支语句
语句是指程序命令,按照顺序执行.可以分为 顺序语句 分支语句 循环语句 之前学习的内容都是按照顺序程序执行的,称之为顺序语句. 今天学的的内容是分支语句. 语句可以嵌套,可以是以分号结尾的单行 ...
- js 两个数组进行去重处理,返回去重后的数组
1.去重的方法为: array_diff(a, b) { for (var i = 0; i < b.length; i++) { for (var j = 0; j < a.length ...
- urllib2功能说明
1.urlopen(url, data, timeout) 第一个参数url即为URL,第二个参数data是访问URL时要传送的数据,第三个timeout是设置超时时间. 第二三个参数是可以不传送的, ...
- Sql Server 自动备份
1)启动代理服务 服务->Sql server 代理启动 2)设置维护计划 维护计划->设置维护计划向导->修改名称及说明 3)更改计划 4)选择维护任务 5)顺序调整不做解释 6) ...
- (1)JSTL的13个core标签库
标准标签库JSTL的全名为:Java Server Pages Standard Tag Library. (jsp standard tag library) JSTL主要提供了5大类标签库: ...
- [Tkinter 教程] 布局管理 (Pack Place Grid)
原系列地址: Python Tkinter 简介: 本文讲述如何使用 tkinter 的布局管理 (被称作 layout managers 或 geometry managers). tkinter ...
- shell脚本,awk如何处理文件中上下关联的两行。
文件d.txt如下内容 ggg 1portals: 192.168.5.41:3260werew 2portals: 192.168.5.43:3260 如何把文件d.txt内容变为如下内容 ggg ...
- docker build no such file or directory
在我构建新的镜像的时候, 发生 了 no such file or directory 的错误. 这个错误找了半天, 没头绪, 后来灵光一现, 原来是我的文件夹名字写错了 我的目录结构是这样的 [ ...