数论
文章平均质量分 68
ChasingWaves
这个作者很懒,什么都没留下…
展开
-
POJ 2480 Longge's problem 欧拉函数的应用 积性函数
找时间把题解补上//176K 157MS #include #include #include using namespace std; typedef long long ll; ll F(ll n){ ll m = sqrt(n+0.5); ll ans = n; for(ll i=2; i<=m; ++i) if(n % i == 0){原创 2014-07-17 16:23:06 · 381 阅读 · 0 评论 -
zoj 3772 Calculate the Function 线段树+矩阵
Time Limit: 2 Seconds Memory Limit: 65536 KB You are given a list of numbers A1 A2 .. AN and M queries. For the i-th query: The query has two parameters Li and Ri. The query will define a funct原创 2014-04-07 18:44:15 · 530 阅读 · 0 评论 -
求欧拉函数
/*欧拉函数:小于n且与n互素的数的个数*/ #include #include int EulerPhi(int n) //求某一个数的欧拉函数值 { int m = sqrt(n+0.5); int ans = n; for(int i=2; i<=m; ++i) if(n % i == 0) { ans = ans/i*(原创 2014-01-12 18:11:52 · 447 阅读 · 0 评论 -
POJ 3483 A Very Simple Problem
Problem Description This is a very simple problem. Given three integers N, x, and M, your task is to calculate out the following value: Input There are several test cases. For each case, th原创 2014-04-06 02:06:22 · 537 阅读 · 0 评论 -
pku 3233 Matrix Power Series
Description Given a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3 + … + Ak. Input The input contains exactly one test case. The first line of input contains three posi原创 2014-03-16 22:49:15 · 411 阅读 · 0 评论 -
hdu 4937 Lucky Number 多校第七场
先用暴力法+解方程统计出两位和三位的个数,再用原创 2014-08-12 23:57:24 · 358 阅读 · 0 评论 -
求模乘法的逆元
void exgcd(LL a, LL b, LL& d, LL& x, LL& y) { if(b == 0) { d = a; x = 1; y = 0; } else { exgcd(b, a%b, d, y, x); y -= x*(a/b); } } LL inv(LL a, LL mod) { LL d,原创 2014-08-08 15:54:43 · 760 阅读 · 0 评论 -
hdu 4920 Matrix multiplication 多校第五场 稀疏矩阵乘法
Problem Description Given two matrices A and B of size n×n, find the product of them. bobo hates big integers. So you are only asked to find the result modulo 3. Input The input consists of原创 2014-08-06 10:21:29 · 404 阅读 · 0 评论 -
POJ 4927 Series 1 多校第六场 杨辉三角的应用
Problem Description Let A be an integral series {A1, A2, . . . , An}. The zero-order series of A is A itself. The first-order series of A is {B1, B2, . . . , Bn-1},where Bi = Ai+1 - Ai. The原创 2014-08-07 19:13:36 · 392 阅读 · 0 评论 -
POJ 1061 青蛙的约会
公青蛙一开始在x位置,母青蛙在y位置。公青蛙每次跳m米,母青蛙每次跳n米,并且都是向右跳的。地球经线长度是L,然后地球是圆的,也就是说,跳到L、L+1、L+2……其实就是跳到0、1、2。 公青蛙想追母青蛙,问多少次后它们能跳到一起。如果它们永远不能相遇,就输出Impossible(好可怜啊!) 很明显嘛,就是求一个k,使x + k*m ≡ y + k*n (mod L) 嘛,木有错吧?至少我转载 2014-07-07 16:13:27 · 330 阅读 · 0 评论 -
扩展欧几里德算法
之前写过的文章,现在粘过来原创 2014-07-07 16:17:02 · 498 阅读 · 0 评论 -
POJ 2739 Sum of Consecutive Prime Numbers 素数打表+尺取法
http://poj.org/problem?id=2739 普通的查原创 2014-07-11 11:17:31 · 377 阅读 · 0 评论 -
武大oj 校赛 Problem 1540 - D - Fibonacci
Description Calculate the sum of the cubes of the first n items in Fibonacci sequence in which the first two are both 1. Input The input consists of one or more test cases. First line of each原创 2014-03-31 11:23:52 · 766 阅读 · 0 评论