
数论
deprecated_tzg
这个作者很懒,什么都没留下…
展开
-
hdu 4549 M斐波那契数列
矩阵乘法的快速幂和乘法的快速幂题目连接。。。其中做了点优化,用该矩阵可由 f0,f1 --> f2,f3 减少计算次数,如果数据量再大点应该看得出来效果最关键的是在矩阵乘法中的取模运算要选 MOD-1,在这被坑的很惨#include#include typedef __int64 ll;const ll MOD = 1000000007;struct matrix原创 2013-06-03 14:36:47 · 658 阅读 · 0 评论 -
hdu 5072 Coprime(容斥)
hdu 5072 Coprime第一次转载 2014-10-29 23:39:50 · 634 阅读 · 0 评论 -
hdu 4910 Problem about GCD(Miller Rabin大素数检测)
hdu 4910 Problem about GCD转载 2014-08-31 21:48:14 · 766 阅读 · 0 评论 -
hdu 4779 Tower Defense(组合数学 枚举)
hdu 4779 Tower Defense转载 2014-08-11 21:15:44 · 1221 阅读 · 0 评论 -
POLYA合集 II
hdu 2481 Toy原创 2014-07-05 17:30:18 · 658 阅读 · 0 评论 -
hdu 4704 Sum(费马小定理)
数论转载 2014-05-02 18:15:17 · 519 阅读 · 0 评论 -
hdu 4661 Message Passing(树形dp)
反正是转载 2014-05-01 21:15:55 · 728 阅读 · 0 评论 -
hdu 4577 X-Boxes(大数)
想用c++来写大数,看来还是不太现实,借鉴了java版的import java.io.*;import java.math.*;import java.util.*;/* * (2x-1)*2^(ky-1) <= n * (2x-1)*2^(ky) <= n*2 */public class Main{ public static void main(String a转载 2014-01-07 18:32:29 · 726 阅读 · 0 评论 -
整数拆分
hdu 4651 Partition原创 2014-07-14 15:49:18 · 664 阅读 · 0 评论 -
扩展欧几里德定理
表示第一次接触该定理原创 2014-07-17 09:59:02 · 614 阅读 · 0 评论 -
数论合集 I
由题意可以得出将U和I都转化为I的方法原创 2014-05-08 19:00:27 · 722 阅读 · 0 评论 -
hdu 4588 Count The Carries
。。。。原创 2014-02-05 15:06:01 · 623 阅读 · 0 评论 -
hdu 4611 Balls Rearrangement
找规律,模拟,计算压缩;最大公因数,最小公倍数#include #include #include #include #include using namespace std;typedef long long ll;/** ∑abs(i%A - i%B) 0<=i<N*/ll getGCD ( ll a, ll b ){ for ( int t; b;原创 2013-08-28 11:16:35 · 501 阅读 · 0 评论 -
hdu 4610 Cards (分解质因数)
数学推导,快速求素数,模拟#include #include #include #include #include using namespace std;typedef long long ll;const int MAXN = 4000010;/** n = a0^b0 * a1*b1 * a2^b2 * a3^b3 ...... a均为素数 因子数原创 2013-08-28 08:13:24 · 825 阅读 · 0 评论 -
hdu 4602 Partition
找规律,分析的水题#includetypedef long long ll;const ll MOD = 1000000007;/* 1 2 5 12 28 64 n = n-k f(n) = 2*f(n-1) + 2^(n-2) n>=2 f(n) = 1 n == 0 f(n) = 2 n == 1 f(n) = 2^2*f(原创 2013-08-07 14:37:52 · 604 阅读 · 0 评论 -
hdu 2243 考研路茫茫——单词情结
矩阵快速幂、幂相加是重点还设计到一些ac自动机的dp#include #include #include using namespace std;typedef unsigned long long ULL;const int MAXN = 60;const int szGP = MAXN*MAXN*(sizeof (ULL));struct tire{ int原创 2013-07-16 21:12:14 · 847 阅读 · 0 评论 -
hdu 4565 So Easy!
数学推导,矩阵快速幂题目连接。。。题目涉及n次方,自然想到用矩阵的快速幂来简化操作,把根号的部分和整数部分分开考虑,不难得出矩阵 [a,b; 1,a],初始的数为[a,1]但是这样一来最后的结果中就要涉及开根号,由于在矩阵幂运算中要mod m ,所以开根号后肯定会出错。幸好网上有大神提供了一种猜想,即整数部分和带根号的部分向上取整的值相同,证明了下,还真是这样。。。[(a+原创 2013-06-06 16:23:16 · 734 阅读 · 0 评论 -
hdu 4533 威威猫系列故事——晒被子
看了网上各大神的解题,才发现不进行数学推导怎么都会超时。。。选了个最简单粗暴的算法,对每个四边形的四个点(x,y),若max(x, y) #include#includeusing namespace std;typedef __int64 ll;const int MAX = 50005;struct node{ ll x, y; int maxnum;原创 2013-05-30 23:41:15 · 625 阅读 · 0 评论 -
POLYA合集
polya计数,费马小定理原创 2014-06-12 19:24:44 · 825 阅读 · 0 评论