【题目分析】

这题貌似在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. How to install Eclipse in linux

    http://askubuntu.com/questions/26632/how-to-install-eclipse

  2. The Django Book - 第四章 模板

    使用模板的最基本方式:1.根据原始模板代码字符串创建一个Template对象2. 使用字典创建一套Context变量3. 调用Template对象的render方法,传入Context变量参数 In ...

  3. Higher level thinking

    「Higher level thinking」-- 出自 Ray Dalio 的<Principles>(PDF 原文:Principles by Ray Dalio) Higher le ...

  4. 基本编程题 --python

    1.让Python帮你随机选一个饮品吧! import random listC = ['加多宝', '雪碧', '可乐', '勇闯天涯', '椰子汁'] print(random.choices(l ...

  5. urllib基础-利用网站结构爬取网页-百度搜索

    有的时候爬取网页,可以利用网站额结构特点爬取网页 在百度搜索框中输入搜索内容,单击搜索,浏览器会发送一个带有参数的url请求.尝试删除其中的一些参数,只剩下wd这个参数.发现wd是搜索内容.这样程序可 ...

  6. 2890: C--去掉+86

    2890: C--去掉+86 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 210  Solved: 91[Submit][Status][Web Bo ...

  7. OpenCV2:介绍

    一.OpenCV简介 OpenCV所有的类和函数都在cv命名空间里面,可以用 using namespace cv; #include "opencv2/opencv.hpp" 1 ...

  8. PHP 头部utf-8

    只是自己用的一些存储,请各位看官大大勿怪. header("Content-Type: text/html;charset=utf-8"); 2019年04月10日

  9. Springboot邮箱接口(使用个人邮箱发送邮件)

    近期项目使用邮件验证,这里使用个人邮箱进行测试,记录开发笔记 SpringBoot自带短信接口 maven pom.xml 引入: <dependency> <groupId> ...

  10. shell脚本,通过传参求斐波那契数列如(0,1,1,2,3,5,8,13..........)

    [root@localhost wyb]# cat fibo.sh #!/bin/bash #斐波那契数列 ,,,,,,, > file >> file count=$ for i ...