摘要:题意:问小于n且不与n互质的数的和是多少。容斥原理求出和n互质的和,然后用 n*(n-1)/2 减以下,注意溢出。#pragma comment(linker,"/STACK:102400000,102400000") #define _CRT_SECURE_NO_WARNINGS#include#...
阅读全文
摘要:就是计算 区间[1,b/k] [1,d/k] 互质的对数,(3,4) 和(4,3)算一种。每次只加比他大的就行了。#pragma comment(linker,"/STACK:102400000,102400000") #define _CRT_SECURE_NO_WARNINGS#include#...
阅读全文
摘要:人在(0,0)点,问n*m的矩阵上的点有多少可以与人直接可见,其实就是矩阵上点与(0,0)点的形成的斜率种类数。#pragma comment(linker,"/STACK:102400000,102400000") #define _CRT_SECURE_NO_WARNINGS#include#i...
阅读全文
摘要:求A到B之间有多少个数能与N互质。学了下容斥原理的写法, 想将N分解质因数,然后容斥原理,N - 单个质因数倍数个数+2个质因数倍数的个数-3个质因数的个数......#define _CRT_SECURE_NO_WARNINGS#include#include#include#include#in...
阅读全文
摘要:转载http://www.cnblogs.com/kuangbin/archive/2012/09/01/2667044.html#include#include#include#include#includeusing namespace std;const int MAXN=50;int a[M...
阅读全文
摘要:题意:1表示开着,0表示关着。当对某个等打开或关闭时,周围四个灯的状态也会改变,让输出一种开关灯的方式。搞法1:高斯消元,不过感觉数据应该有问题,我解方程是按一定会存在唯一一组解的情况写的。#include #include #include #include #include #include #...
阅读全文
摘要:比赛的时候不会写,但是网上有基本一样的题。出题水了。。这题把每个数拆成2进制,然后就和开关灯一样了。然后学了下高斯消元kuangbin大神的高斯消元模板。http://www.cnblogs.com/kuangbin/archive/2012/09/01/2667044.html#include#i...
阅读全文
摘要:高斯消元的入门题。#include#include#include#include#include#includeusing namespace std;int Map[100][100];int gauss(int equ, int var){ int k; int col; for ...
阅读全文
摘要:和上题差不多一样的搞法。#include#include#include#include#include#includeusing namespace std;const int maxn = 111111;int a[maxn]; int b[maxn];int vis[maxn];int mai...
阅读全文
摘要:一定存在连续的k个数,使得他们的和能被n整除。设a[i]为前缀和a[1]%n ,a[2]%n,...,a[n]%n的值的范围#include#include#include#include#includeusing namespace std;typedef long long LL;int m...
阅读全文
摘要:每一列能由前一列推过来,构造一个(n+2)*(n+2)的矩阵B,第k列 就等于 所构造的第一列A*B^(k-1)比如233 10 10 10 0 2333a1+233 * 1 1 0 = a1+233+2333a1+a2...
阅读全文
摘要:转个图。或者打表找的规律是 g[n] = 3*g[n-1] - g[n-2];构造个 3 -1 的矩阵然后搞下就好了。 1 0 #include #include #include #include typedef long long LL;using namespace std;LL mod...
阅读全文
摘要:ai = (ai-1 + ai) %2 然后构造个 n*n的矩阵A, 时间K之后的状态就是 A^k * B(给出的字符串)#include #include #include #include typedef long long LL;using namespace std;int n;struct...
阅读全文
摘要:矩阵相乘,判断之后建图。 注意 A B C三个互不相同的城市#include #include #include #include typedef long long LL;using namespace std;const int INF = 0xfffffff;struct Matrix{...
阅读全文
摘要:判断i到j 是否k步可达。#include #include #include #include typedef long long LL;using namespace std;int n;int x[100], y[100];struct Matrix{ int m[40][40];...
阅读全文
摘要:前面就做过了。。。二分搞下#include #include #include #include typedef long long LL;using namespace std;int n, M;struct Matrix{ int m[40][40];};Matrix Mul(Matrix...
阅读全文
摘要:矩阵快速幂,就是快速幂的乘法变成矩阵乘法,其余的都一样。#include #include #include #include using namespace std;const int mod = 9973;const int maxn = 12;struct Matrix{ int m[m...
阅读全文
摘要:给定一个有向图,问从A点恰好走k步(允许重复经过边)到达B点的方案数mod p的值。详见matrix67博客http://www.matrix67.com/blog/archives/276#include #include #include #include typedef long long L...
阅读全文
摘要:构造个矩阵搞下就行了a0 a1 a2 a3 a4 a5 a6 a7 a8 a91 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 00 0 0 1 0 0 0 0 0 00 0 0 0 1 ...
阅读全文
摘要:题意:求g(i)=k*i+b; f(g(i)) for 0#include #include #include typedef long long LL;LL M;using namespace std;struct Matrix{ LL m[4][4];};Matrix Mul(Matrix...
阅读全文