Hdu 5833 Zhu and 772002 异或方程组高斯消元
来源:互联网 发布:mac os app store更新 编辑:程序博客网 时间:2024/06/05 05:40
Zhu and 772002
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2342 Accepted Submission(s): 850
Problem Description
Zhu and 772002 are both good at math. One day, Zhu wants to test the ability of 772002, so he asks 772002 to solve a math problem.
But 772002 has a appointment with his girl friend. So 772002 gives this problem to you.
There aren 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 makeb is a perfect square number. The answer maybe too large, so you should output the answer modulo by 1000000007 .
But 772002 has a appointment with his girl friend. So 772002 gives this problem to you.
There are
How many different ways of choices can make
Input
First line is a positive integer T , represents there are T test cases.
For each test case:
First line includes a numbern(1≤n≤300) ,next line there are n numbers a1,a2,...,an,(1≤ai≤1018) .
For each test case:
First line includes a number
Output
For the i-th test case , first output Case #i: in a single line.
Then output the answer of i-th test case modulo by1000000007 .
Then output the answer of i-th test case modulo by
Sample Input
233 3 432 2 2
Sample Output
Case #1:3Case #2:3
Author
UESTC
Source
2016中国大学生程序设计竞赛 - 网络选拔赛
有n个最大质因子不超过2000的数字,问从中选数使得乘积是完全平方数的方案有多少种。
用Xi=0/1表示第i个数选/不选。要使乘积为完全平方数,则把乘积质因数分解后,每个质因数的次数都为偶数。由此对每个可能的质因子构造关于Xi的异或方程组求解,求出自由元素的个数m,答案就是2^m-1.(需要减去什么也不选的方案)
刘汝佳白书P160原题
#include <cstdio>#include <iostream>#include <string.h>#include <string> #include <map>#include <queue>#include <deque>#include <vector>#include <set>#include <algorithm>#include <math.h>#include <cmath>#include <stack>#include <iomanip>#define mem0(a) memset(a,0,sizeof(a))#define meminf(a) memset(a,0x3f,sizeof(a))#define MAX 2000using namespace std;typedef long long ll;typedef long double ld;typedef double db;const int maxn=100005,inf=0x3f3f3f3f; const ll llinf=0x3f3f3f3f3f3f3f3f,mod=1e9+7; const ld pi=acos(-1.0L);ll a[maxn],p[maxn],r[405][405];bool prime[MAX+5];int num=0;void init() {mem0(prime);int i,j;for (i=2;i<=MAX;i++) {if (!prime[i])p[num++]=i;for (j=0;j<num&&i*p[j]<=MAX;j++) {prime[i*p[j]]=1;if (i%p[j]==0) break;}}}ll fastpower(ll base,ll index) {ll ans,now;if (index<=0) return 1;ans=1;now=base;ll k=index;while (k) {if (k%2) ans=ans*now;ans%=mod;now=now*now;now%=mod;k/=2;}return ans;}ll gauss(int n,int m) {int i,j,k,l;i=j=0;while (i<n&&j<m) {int q=-1;for (k=i;k<n;k++) if (r[k][j]) {q=k;break;}if (q==-1) {j++;continue;}for (k=j;k<m;k++) swap(r[i][k],r[q][k]);for (k=i+1;k<n;k++) {if (r[k][j])for (l=j;l<m;l++) r[k][l]^=r[i][l];}i++;}return i; //有界变量数量即为消元次数 }int main() {int cas,cnt=0;scanf("%d",&cas);init();while (cas--) {int n,i,j;cnt++;printf("Case #%d:\n",cnt);scanf("%d",&n);mem0(r);for (i=0;i<n;i++) {scanf("%I64d",&a[i]);for (j=0;j<num;j++) {while (a[i]%p[j]==0) {a[i]/=p[j];r[j][i]^=1;}}}ll w=n-gauss(num,n);ll ans=fastpower(2,w)-1;printf("%I64d\n",ans);}return 0;}
阅读全文
0 0
- 【HDU 5833】【异或方程组高斯消元】Zhu and 772002
- HDU 5833 Zhu and 772002(异或方程组高斯消元)
- Hdu 5833 Zhu and 772002 异或方程组高斯消元
- Hdu 5833 Zhu and 772002(高斯消元解异或方程组)
- [hdu 5833 Zhu and 772002] 高斯消元求异或方程组
- HDU-5833 Zhu and 772002(异或方程高斯消元)
- HDU 5833 Zhu and 772002 高斯消元解异或方程组,求自由元个数,bitset压位
- hdu5833 Zhu and 772002 【高斯消元解异或方程组】
- HDU5833(2016CCPC网赛)——Zhu and 772002(异或方程组,素数分解)
- Hdu-5833 Zhu and 772002(高斯消元)
- hdu 5833 Zhu and 772002(高斯消元)
- HDU 5833 Zhu and 772002 (高斯消元)
- HDU 5833 Zhu and 772002 (高斯消元)
- HDU 5833 Zhu and 772002 高斯消元
- HDU 5833 Zhu and 772002(高斯消元)
- [HDU 5833] Zhu and 772002 (高斯消元)
- HDU-5833-Zhu and 772002(高斯消元)
- hdu 5833 Zhu and 772002 高斯消元
- Hbase_命令
- 低层视觉:使用一幅图像——边缘检测
- Java多线程
- 什么星座更适合做程序猿?
- LNMP架构(二)
- Hdu 5833 Zhu and 772002 异或方程组高斯消元
- Zookeeper异常Exception in thread "main" org.apache.zookeeper.KeeperExcep
- myeclipse选中的变量,相关引用的地方高亮
- Python 练习实例16
- OVN架构原理
- 输入一个正整数n,获得该整数低字节中的前4位,并按示例格式输出。
- 实验三 线性方程组的直接解法
- java之接口(interface)和抽象(abstract)关键字详解
- Python画等高线