链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4510 题意: 对于给定的n个数a1, a2,…, an,依次求出相邻两数之和,将得到一个新数列.重复上述操作,最后结果将变成一个数.问这个数除以m的余数与哪些数无关?例如n=3,m=2时,第一次求和得到a1+a2,a2+a3,再求和得到a1+2a2+a3,它除以2的余数和a2无关.…
https://vjudge.net/problem/UVA-1635 题意:n个数,每相邻两个求和,最后变成1个数,问这个数除m的余数与第几个数无关 n个数使用次数分别为C(n-1,i) i∈[0,n-1] 对m分解质因数 同行内递推C(n-1,i), 累计答案的时候,只考虑C(n-1,i)分解质因数的结果  能否 将m的质因数 抵消 #include<cmath> #include<cstring> #include<cstdio> #define N 100001…
UVA.10791 Minimum Sum LCM (唯一分解定理) 题意分析 也是利用唯一分解定理,但是要注意,分解的时候要循环(sqrt(num+1))次,并要对最后的num结果进行判断. 代码总览 #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #define nmax 505 #define ll long long using namespace…
UVA - 10375 Choose and divide Choose and divide Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4053   Accepted: 1318 Description The binomial coefficient C(m,n) is defined as m! C(m,n) = -------- n!(m-n)! Given four natural numbers p, q…
Young cryptoanalyst Georgie is investigating different schemes of generating random integer numbers ranging from 0 to m − 1. He thinks that standard random number generators are not good enough, so he has invented his own scheme that is intended to b…
题目链接:https://vjudge.net/contest/156903#problem/E 题意:已知 求:C(p,q)/C(r,s) 其中p,q,r,s都是10^4,硬算是肯定超数据类型的. 可以这样处理:利用唯一分解式约分: 首先将所有数,唯一分解:最后,算素数的乘积: #include <bits/stdc++.h> using namespace std; ; vector<int> primes; int e[maxn]; bool is_prime(int n)…
/** 题目:Irrelevant Elements UVA - 1635 链接:https://vjudge.net/problem/UVA-1635 题意:給定n,m;題意抽象成(a+b)^(n-1)按照二次项分布后每个系数的值按照位置分别为c1,c2,c3...: 如果ci%m==0; 那么输出这个位置. 思路:已知n,计算系数的方法:c(n,m) = (n-m+1)/m*c(n,m-1) ;由于c(n,m-1)%m不一定等于0.所以要先乘. 由于n达到了1e5,所以如果算结果是不可行的.…
Irrelevant Elements Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 2407   Accepted: 597 Case Time Limit: 2000MS Description Young cryptoanalyst Georgie is investigating different schemes of generating random integer numbers ranging from…
题意:求C(p,q)/C(r,s),4个数均小于10000,答案不大于10^8 思路:根据答案的范围猜测,不需要使用高精度.根据唯一分解定理,每一个数都可以分解成若干素数相乘.先求出10000以内的所有素数,用a数组表示唯一分解式中个素数的指数,求出每个分子部分的素因子,并且相应的素数的指数加一.分母则减一.最后求解唯一分解式的值. #include<stdio.h> #include<string.h> #include<math.h> ; int pr[N],p[N…
题意:给出n,求至少两个正整数,使得它们的最小公倍数为n,且这些整数的和最小 看的紫书--- 用唯一分解定理,n=(a1)^p1*(a2)^p2---*(ak)^pk,当每一个(ak)^pk作为一个单独的数的时候,和最小 然后就有三种情况 普通的,比如,2*3*3*5,sum=2+9+5=16 只有1个因数的,比如32=2^5,sum=32+1; 没有因数,自己本身是质数,sum=n+1: 因为分解的时候是找到根号n的,比如21,最后还会剩下7,所以sum=sum+n #include<iost…