2016中国大学生程序设计竞赛 - 网络选拔赛 1002 Zhu and 772002 hdu5833
来源:互联网 发布:淘宝一元包邮怎么赚钱 编辑:程序博客网 时间:2024/05/29 13:53
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
听说是白书原题。
直接按照质因子列异或方程组高斯消元即可
ans=2^自由元个数-1
#include<map>#include<cmath>#include<queue>#include<vector>#include<cstdio>#include<string>#include<cstring>#include<iostream>#include<algorithm>using namespace std;long long mod=1000000007;int prime[2001];bool check[2001]; int tot;inline void prepare(){ memset(check,false,sizeof(check)); int i,j; for(i=2;i<=2000;i++) { if(!check[i]) { tot++; prime[tot]=i; } for(j=1;j<=tot;j++) { if(i*prime[j]>2000) break; check[i*prime[j]]=true; } }}int a[400][400],x[400],free_x[400]; int equ,var,free_num;long long b[301];int Gauss(){ int max_r,col,k; free_num=0; for(k=0,col=0;k<equ&&col<var;k++,col++){ max_r=k; for(int i=k+1;i<equ;i++){ if(abs(a[i][col])>abs(a[max_r][col])) max_r=i; } if(a[max_r][col]==0){ k--; free_x[free_num++]=col; continue; } if(max_r!=k){ for(int j=col;j<var+1;j++) swap(a[k][j],a[max_r][j]); } for(int i=k+1;i<equ;i++){ if(a[i][col]!=0){ for(int j=col;j<var+1;j++) a[i][j]^=a[k][j]; } } } for(int i=k;i<equ;i++) if(a[i][col]!=0) return -1; return var-k;}int main(){prepare();int T,k=0;scanf("%d",&T);while(T>0){T--;k++;int n;scanf("%d",&n);equ=tot;var=n; memset(a,0,sizeof(a)); memset(x,0,sizeof(x)); int i,j; for(i=1;i<=n;i++) scanf("%I64d",&b[i]); for(i=1;i<=n;i++) { long long t=b[i]; for(j=1;j<=tot;j++) { int sx=0; while(t%prime[j]==0) { t/=prime[j]; sx++; } if(sx%2==1) a[j-1][i-1]=1; } } int p=Gauss(); long long ans=1; for(i=1;i<=p;i++) ans=ans*(long long)2%mod;ans=(ans+mod-1)%mod; printf("Case #%d:\n%I64d\n",k,ans);}}
0 0
- 2016中国大学生程序设计竞赛 - 网络选拔赛 hdu5833 Zhu and 772002
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1002 Zhu and 772002 hdu5833
- HDU 5833 Zhu and 772002(高斯消元)——2016中国大学生程序设计竞赛 - 网络选拔赛
- HDU 5833 Zhu and 772002 2016中国大学生程序设计竞赛 - 网络选拔赛(高斯消元)
- hdu 5833 Zhu and 772002 2016中国大学生程序设计竞赛 - 网络选拔赛1002 [质因子分解+高斯消元]【数论】
- HDUOJ5832Lweb and String&&2016中国大学生程序设计竞赛 - 网络选拔赛1011
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1011 Lweb and String
- 2016中国大学生程序设计竞赛 - 网络选拔赛
- 2016中国大学生程序设计竞赛 - 网络选拔赛
- 2016中国大学生程序设计竞赛网络选拔赛
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1001
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1011
- 2016中国大学生程序设计竞赛 - 网络选拔赛
- hdu5833 Zhu and 772002
- hdu5833 Zhu and 772002
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1011 Lweb and String hdu5842
- 2016中国大学生程序设计竞赛 - 网络选拔赛题解报告
- 2016中国大学生程序设计竞赛 - 网络选拔赛——题目笔记
- 细说oracle 11g rac 的ip地址
- 【搬自usaco2015Dec】【JZOJ4684】卡牌游戏 题解
- 如何将WebRoot部署到tomcat中
- STM8 定时计数器2
- Sublime支持汇编
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1002 Zhu and 772002 hdu5833
- java不一样的单例模式
- 安卓开发,listview的优化,减少内存消耗,复用convertView、ViewHolder和分页加载
- 判断是否回文数
- php代码使用36个小技巧
- 笔记,c++中静态对象在程序结束的时候会不会进析构函数?
- 数据库
- this关键字
- 找出有序数组中和等于指定数的两个数