$\gcd(ab,k)=\gcd(\gcd(a,k)\times \gcd(b,k),k)$ 设$f[i][j]$表示前$i$行,与$k$的$\gcd$为$j$的方案数,$h[i]$表示当前行选一个或两个,乘积与$k$的$\gcd$为$i$的方案数,然后DP即可. 时间复杂度$O(N(M+K))$. #include<cstdio> #define N 165 typedef long long ll; int n,m,K,L,i,j,k,d,a[N],id[200005],g[N][N],c
A- Theatre Square Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Description Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city's anniversary, a
联系: http://soj.me/1732 Constraints Time Limit: 1 secs, Memory Limit: 32 MB Description: Alice is a beautiful and clever girl. Bob would like to play with Alice. One day, Alice got a very big rectangle and wanted to divide it into small square pieces.
ZOJ Problem Set - 3593 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3593 One Person Game Time Limit: 2 Seconds Memory Limit: 65536 KB There is an interesting and simple one person game. Suppose there is a number axis under your f
CRT, lucas及其扩展形式 exgcd int exgcd(int a, int b, int &x, int &y) { if (b == 0) return a, x = 1, y = 0; int y = exgcd(b, a % b, x, y), t; t = x, x = y, y = t - a / b * y; } 证明: gcd的过程中, 假设我们已经求出了\(b * x + (a~\%~b) * y = gcd(a, b)\)推导到\(a*x + b*y = gc