题目链接 题意:给定n个数,这n个数的素因子值不超过2000,从中取任意个数使其乘积为完全平方数,问有多少种取法. 题解:开始用素筛枚举写了半天TLE了,后来队友说高斯消元才想起来,果断用模板.赛后又得知这是个原题sgu200,真坑啊.把每个数进行素因子分解,素因子a的幂为奇数则视为1,偶数则视为0,转化为从n个数中取数异或和为0有多少种取法的问题. AC代码: #include <cstdio> #include <cstring> #include <cmath>…
Zhu and 772002 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5833 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 g…
题意:给n个数,从n个数中抽取x(x>=1)个数,这x个数相乘为完全平方数,求一共有多少种取法,结果模1000000007. 思路:每个数可以拆成素数相乘的形式,例如: x1 2=2^1 * 3^0 * 5^0; x2 3=2^0 * 3^1 * 5^0; x3 4=2^2 * 3^0 * 5^0; x4 5=2^0 * 3^0 * 5^1; x5 6=2^1 * 3^1 * 5^0; x6 15=2^0 * 3^1 * 5^1; 用xi表示第i个数选或不选,xi的取值为0或1:因为相乘结果为完…
网络预选赛的题目……比赛的时候没有做上,确实是没啥思路,只知道肯定是整数分解,然后乘起来素数的幂肯定是偶数,然后就不知道该怎么办了… 最后题目要求输出方案数,首先根据题目应该能写出如下齐次方程(从别人那里盗的……): a11*x1  ^  a12*x2  ^  ...  ^  a1n*xn=0 a21*x1  ^  a22*x2  ^  ...  ^  a2n*xn=0 ... an1*x1  ^  an2*x2  ^  ...  ^  ann*xn=0,Aij表示选的第j个数的第i个质数(可能…
HDU 5833 Zhu and 772002 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) 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 pro…
传送门:hdu 5833 Zhu and 772002 题意:给n个数,每个数的素数因子不大于2000,让你从其中选则大于等于1个数相乘之后的结果为完全平方数 思路: 小于等于2000的素数一共也只有305个 一个数,如果他某个素数因子的幂为偶,那这个素数的可以不用考虑:如果幂为奇数,那这个素数就应当被考虑如何与其他数凑成幂为偶数.例如12,可以表示为2^2*3,2的幂次为2,3的幂次为1,所以,如果要和其他数相乘为完全平方数,那么一定要与素数因子3为奇次的合并 那么根据上面两条,我们可以列出方…
Zhu and 772002 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 y…
[题目分析] 这题貌似在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…
http://acm.hdu.edu.cn/showproblem.php?pid=5955 题意:给你长度为l的n组数,每个数1-6,每次扔色子,问你每个串第一次被匹配的概率是多少 题解:先建成ac自动机构造fail数组,然后因为fail指针可能向前转移所以不能不能直接递推dp,需要高斯消元解方程,对于节点i,假设不是结束点而且能转移到它的点有a1,a2...an,那么dp[i]=1/6*dp[a1]+1/6*dp[a2]+...+1/6*a[n],然后我们可以列出n个方程,高斯消元然后找到每…
[BZOJ3601]一个人的数论 题解:本题的做法还是很神的~ 那么g(n)如何求呢?显然它的常数项=0,我们可以用待定系数法,将n=1...d+1的情况代入式子中解方程,有d+1个方程和d+1个未知数,直接高斯消元解出ai即可. #include <cstdio> #include <cstring> #include <iostream> using namespace std; typedef long long ll; const ll P=1000000007…