hdu 5833 Zhu and 772002 高斯消元
Zhu and 772002
But 772002 has a appointment with his girl friend. So 772002 gives this problem to you.
There are n numbers a1,a2,...,an. The value of the prime factors of each number does not exceed 2000, you can choose at least one number and multiply them, then you can get a number b.
How many different ways of choices can make b is a perfect square number. The answer maybe too large, so you should output the answer modulo by 1000000007.
For each test case:
First line includes a number n(1≤n≤300),next line there are n numbers a1,a2,...,an,(1≤ai≤1018).
Then output the answer of i-th test case modulo by 1000000007.
3
3 3 4
3
2 2 2
3
Case #2:
3
题意:
给你n个数,每个数的素数因子最大不超过2000,从n个数取出任意个至少一个,问有多少种方案使得数的乘积为完全平方数。
题解:
将所有素数处理出来
答案就是 每种素数个数为偶数个
将每个素数使用个数设为x 那么最终mod 2 = 0
那么有303个这样的方程
高斯消元求解异或方程组
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
#define ls i<<1
#define rs ls | 1
#define mid ((ll+rr)>>1)
#define pii pair<int,int>
#define MP make_pair
typedef long long LL;
const long long INF = 1e18;
const double Pi = acos(-1.0);
const int N = 2e3+, M = 1e6, mod = , inf = 2e9; int p[N],H[N],cnt,A[][],mx,ini[N];
LL a[N];
void init() {
for(int i = ; i <= ; ++i) {
if(!H[i]) {
p[cnt++] = i;
for(int j = i+i; j <= ; j += i) {
H[j] = ;
}
}
}
ini[] = ;
for(int i = ; i<= ; ++i) ini[i] = ini[i-]*%mod;
}
LL Guass(int n,int m) {
int i, j;
for(i = , j = ; i < n && j < m; ) {
int x = -;
for(int k = i; k < n; ++k) {
if(A[k][j]) {
x = k;
break;
}
}
if(x == -) {
++j;
continue;
}
for(int k = ; k <= m; ++k) swap(A[i][k],A[x][k]);
for(int u = i+; u < n; ++u) {
if(A[u][j]) {
for(int k = ; k <= m; ++k) {
A[u][k] ^= A[i][k];
}
}
}
++i;
++j;
}
return m-i;
}
int main() {
int T,cas = ,n;
init();
scanf("%d",&T);
while(T--) {
scanf("%d",&n);
mx = ;
for(int i = ; i < n; ++i) scanf("%I64d",&a[i]);
memset(A,,sizeof(A));
for(int i = ; i < n; ++i) {
for(int j = ; j < cnt; ++j) {
while(a[i] % p[j] == ) {
A[j][i] ^= ;
a[i] /= p[j];
mx = max(mx,j+);
}
}
}
printf("Case #%d:\n",cas++);
cout<<ini[Guass(mx,n)] - <<endl;
}
return ;
}
hdu 5833 Zhu and 772002 高斯消元的更多相关文章
- HDU - 5833: Zhu and 772002 (高斯消元-自由元)
pro:给定N个数Xi(Xi<1e18),保证每个数的素因子小于2e3:问有多少种方案,选处一些数,使得数的乘积是完全平方数.求答案%1e9+7: N<300; sol:小于2e3的素数只 ...
- 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 ccpc网络赛 高斯消元法
传送门:hdu 5833 Zhu and 772002 题意:给n个数,每个数的素数因子不大于2000,让你从其中选则大于等于1个数相乘之后的结果为完全平方数 思路: 小于等于2000的素数一共也只有 ...
- HDU 5833 Zhu and 772002 (高斯消元)
Zhu and 772002 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5833 Description Zhu and 772002 are b ...
- HDU 5755 Gambler Bo(高斯消元)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5755 [题目大意] 一个n*m由0,1,2组成的矩阵,每次操作可以选取一个方格,使得它加上2之后对 ...
- HDU 4818 RP problem (高斯消元, 2013年长春区域赛F题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4818 深深地补一个坑~~~ 现场赛坑在这题了,TAT.... 今天把代码改了下,过掉了,TAT 很明显 ...
- ACM学习历程—HDU 3949 XOR(xor高斯消元)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3949 题目大意是给n个数,然后随便取几个数求xor和,求第k小的.(重复不计算) 首先想把所有xor的 ...
- 2014多校第一场J题 || HDU 4870 Rating(DP || 高斯消元)
题目链接 题意 :小女孩注册了两个比赛的帐号,初始分值都为0,每做一次比赛如果排名在前两百名,rating涨50,否则降100,告诉你她每次比赛在前两百名的概率p,如果她每次做题都用两个账号中分数低的 ...
- HDU 3571 N-dimensional Sphere(高斯消元 数论题)
这道题算是比较综合的了,要用到扩展欧几里得,乘法二分,高斯消元. 看了题解才做出来orz 基本思路是这样,建一个n*(n-1)的行列式,然后高斯消元. 关键就是在建行列式时会暴long long,所以 ...
随机推荐
- 学 Redux (转)
0.官方文档:http://redux.js.org/ 中文版本 : http://cn.redux.js.org/ 中文版本(好!): http://www.css88.com/react/d ...
- cxGrid 增加序号 (非数据库绑定模式) (测试通过)
cxGrid 增加序号 (非数据库绑定模式) ----------------------------------- 1. 选在 adoQuery 控件 , 鼠标右键菜单中 选择 Fields Edi ...
- 23. javacript高级程序设计-数据存储
1. 数据存储 1.1 cookie HTTP Cookie, cookie,最初用来在客户端存储回话信息. (1). 限制,不同浏览器对特定域名下的cookie 的个数有限制,每个域名下最好不要操过 ...
- INNODB自增主键的一些问题
背景: 自增长是一个很常见的数据属性,在MySQL中大家都很愿意让自增长属性的字段当一个主键.特别是InnoDB,因为InnoDB的聚集索引的特性,使用自增长属性的字段当主键性能更好,这里要说明下自增 ...
- java 入门 第二季2
(1). 封装 封装类的时候属性用private,方法getter和setter用public 将类的某些信息隐藏在类内部,不允许外部程序直接访问,而是通过该类提供的方法来实现对隐藏信息的操作和访问 ...
- Debian 配置apt-get源
1.配置apt-get源 cp /etc/apt/sources.list /etc/apt/sources.listbak #备份原有配置文件 nano /etc/apt/so ...
- 1.openstack之mitaka搭建基本配置
介绍:本次案列为基本的三节点部署 注:搭建所需要的包可以联系QQ:22102107获取 一:网络: 1.管理网络:192.168.11.0/24 2.数据网络:1.1.1.0/24 注:每个节点两个网 ...
- ASM:《X86汇编语言-从实模式到保护模式》5-7章:汇编基础
第5-7章感觉是这一本书中比较奇怪的章节,可能是作者考虑到读者人群水平的差异,故意由浅入深地讲如何在屏幕上显示字符和使用mov,jmp指令等等,但是这样讲的东西有点重复,而且看了第六,第七章以后,感觉 ...
- VC++ 之常见内存异常值
0 VC++ 常见的内存异常值 * 0xcccccccc : Used by Microsoft's C++ Debugging runtime library to mark uninitialis ...
- BestCoder22 1002.NPY and arithmetic progression(hdu 5143) 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5143 题目意思:给出 1, 2, 3, 4 的数量,分别为a1, a2, a3, a4,问是否在每个数 ...