摘要:
《训练指南》p.125设f[n] = gcd(1, n) + gcd(2, n) + …… + gcd(n - 1, n);则所求答案为S[n] = f[2]+f[3]+……+f[n];求出f[n]即可递推求得S[n]:S[n] = S[n - 1] + f[n];所有gcd(x, n)的值都是n的约数,按照约数进行分类,令g(n, i)表示满足gcd(x, n) = i && x #include #include #include #define LL long long intusing namespace std;const int MAXN = 4000100;LL 阅读全文
posted @ 2013-09-05 21:47
冰鸮
阅读(208)
评论(0)
推荐(0)
摘要:
构造矩阵.见《训练指南》p156...#include #include #include #define LL long long intusing namespace std;const int MAXN = 20;LL mod;struct Matrix{ LL a[MAXN][MAXN]; int r, c; friend Matrix operator*( Matrix &a, Matrix &b ); friend Matrix operator^( Matrix a, LL k );};Matrix operator*( Matrix &a, Matrix 阅读全文
posted @ 2013-09-05 09:15
冰鸮
阅读(258)
评论(0)
推荐(0)

浙公网安备 33010602011771号