Super Poker II UVA - 12298 FFT_生成函数】的更多相关文章

Code: #include<bits/stdc++.h> #define maxn 1000000 #define ll long long #define double long double #define setIO(s) freopen(s".in","r",stdin), freopen(s".out","w",stdout) using namespace std; struct cpx { doub…
UVA - 12298 Super Poker II NTT 链接 Vjudge 思路 暴力开个桶,然后统计,不过会T,用ntt或者fft,ntt用个大模数就行了,百度搜索"NTT大模数". 错误 我也不知道,改着改着自己就A了 思路 #include <bits/stdc++.h> #define ll long long using namespace std; const ll N=1e7+7,mod=39582418599937LL; char s; bool vi…
题目 Source http://acm.hust.edu.cn/vjudge/problem/23590 Description I have a set of super poker cards, consisting of an infinite number of cards. For each positive composite integer p, there are exactly four cards whose value is p: Spade(S), Heart(H),…
Description I have a set of super poker cards, consisting of an infinite number of cards. For each positive composite integer p, there are exactly four cards whose value is p: Spade(S), Heart(H), Club(C) and Diamond(D). There are no cards of other va…
题意:有四种花色的牌,每种花色的牌中只能使用数值的约数个数大于2的牌.现在遗失了c张牌.每种花色选一张,求值在区间[a,b]的每个数值的选择方法有多少. 分析:约数个数大于2,即合数.所以先预处理出50000内的所有素数. 然后根据给出的c个遗失牌和素数与否.构造生成多项式,因为上限是b,所以每个多项式只需构造b项即可.4类牌对应4个多项式,求三次卷积求出答案. 坑点:复数类里要用long double #include<bits/stdc++.h> using namespace std;…
#include<cstdio> #include<cmath> #include<cstring> #include<algorithm> using namespace std; const int N = 1000005; const long double pi = acos(-1.0); struct Complex { long double r,i; Complex(long double r=0, long double i=0):r(r),…
题目:就是现在有一堆扑克里面的牌有无数张, 每种合数的牌有4中不同花色各一张(0, 1都不是合数), 没有质数或者大小是0或者1的牌现在这堆牌中缺失了其中的 c 张牌, 告诉你a, b, c接下来c张不同的丢失的牌, 然后求从这堆牌中拿出各种花色的牌各一张, 得到的点数和是k的种数有多少种(一种组合算作一种), 需要全部所有的a <= k <= b的k对应的结果. 让一个多项式的每一位代表一个数字(总共4个多项式),发现如果第一位代表数字0,则其乘法的性质刚好符合加法的条件(第i位与第j位相加…
怎么又是没人写题解的UVA好题,个人感觉应该是生成函数的大板子题了. 直接做肯定爆炸,考虑来一发优化,我们记一个多项式,其中\(i\)次项的系数就表示对于\(i\)这个数有多少种表示方式. 那么很明显,我们可以先筛素数,那么初始的多项式只有范围的的素数对应项系数才为\(1\),否则都为\(0\). 然后考虑两种花色配对,其实就是看任意两张牌上面的数字加起来能得到什么. 说具体点就是配对后某个项的系数就是两种花色中项的次数之和为这个次数的所有系数之和. 所以我们发现配对的本质其实就是卷积,那么就可…
G(i) = (gcd(1, i) + gcd(2, i) + gcd(3, i) + .....+ gcd(i-1, i)) ret = G(1) + G(2) + G(3) +.....+ G(n); 对于gcd(x,i),我们设gcd(x,i) = m 即x和i的最大公约数为m  则x/m 和 i/m 互质 然后我们求出于i/m互质的有多少个 是不是就是求出了与i最大公约数为m的有多少个..用欧拉函数既能求出个数  ...即为phi(i/m)个  用双重循环  外层循环为m内层循环为i,…
Given the value of N , you will have to nd the value of G . The de nition of G is given below: G = i<N ∑ i =1 j N ∑ j = i +1 GCD ( i; j ) Here GCD ( i; j ) means the greatest common divisor of integer i and integer j . For those who have trouble unde…