算法之数学
cc_wood
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Another Easy Problem FZU - 1753唯一分解定理
题目链接小TT最近学习了高斯消元法解方程组,现在他的问题来了,如果是以下的方程,那么应该如何解呢?C(n1,m1)==0 (mod M)C(n2,m2)==0 (mod M)C(n3,m3)==0 (mod M)................C(nk,mk)==0 (mod M)小TT希望你告诉他满足条件的最大的M其中C(i,j)表示组合数,例如C(5,2)=10,C(4,2)=6...Inpu原创 2017-09-29 21:23:32 · 489 阅读 · 0 评论 -
ACM计算几何题目推荐
一。点,线,面,形基本关系,点积叉积的理解POJ 2318 TOYS(推荐) http://acm.pku.edu.cn/JudgeOnline/problem?id=2318 POJ 2398 Toy Storage(推荐) http://acm.pku.edu.cn/JudgeOnline/problem?id=2398 一个矩形,有被若干直线分成N个格子,给出一个点的坐标,问你该点位于转载 2017-08-23 11:13:13 · 1918 阅读 · 0 评论 -
GCD & LCM Inverse POJ - 2429 Pollard_rho大数因子分解
题目链接Given two positive integers a and b, we can easily calculate the greatest common divisor (GCD) and the least common multiple (LCM) of a and b. But what about the inverse? That is: given GCD and LCM原创 2017-08-25 11:53:47 · 620 阅读 · 0 评论 -
Prime Test POJ - 1811 miller素数判断&pollar_rho大数分解
题目链接Given a big integer number, you are required to find out whether it's a prime number. InputThe first line contains the number of test cases T (1 <= T <= 20 ), then the following T lines each conta原创 2017-08-25 11:09:58 · 794 阅读 · 0 评论 -
Prime Distance POJ - 2689素数筛法
题目链接The branch of mathematics called number theory is about properties of numbers. One of the areas that has captured the interest of number theoreticians for thousands of years is the question of prim原创 2017-08-25 10:23:45 · 459 阅读 · 0 评论 -
Magic Bracelet POJ - 2888 Burnside引理+数论+DP矩阵优化
题目链接Ginny’s birthday is coming soon. Harry Potter is preparing a birthday present for his new girlfriend. The present is a magic bracelet which consists of n magic beads. The are m kinds of different m原创 2017-08-25 10:10:10 · 634 阅读 · 0 评论 -
Necklace of Beads POJ - 1286 polya定理
题目链接Beads of red, blue or green colors are connected together into a circular necklace of n beads ( n < 24 ). If the repetitions that are produced by rotation around the center of the circular necklace原创 2017-08-24 21:15:46 · 434 阅读 · 0 评论 -
Color POJ - 2154 polya定理 + 欧拉优化
[题目链接](http://poj.org/problem?id=2154)Beads of N colors are connected together into a circular necklace of N beads (N<=1000000000). Your job is to calculate how many different kinds of the necklace can原创 2017-08-24 21:06:42 · 455 阅读 · 0 评论 -
Let it Bead POJ - 2409 Polya定理
[题目链接](http://poj.org/problem?id=2409)"Let it Bead" company is located upstairs at 700 Cannery Row in Monterey, CA. As you can deduce from the company name, their business is beads. Their PR department原创 2017-08-24 20:24:20 · 568 阅读 · 0 评论 -
LightOJ 1138 Trailing Zeroes (III)
题目链接:点我You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. As you know N! = 1*2*...*N. For example, 5! = 120, 120 contains one zero on t原创 2017-07-29 11:42:40 · 353 阅读 · 0 评论 -
LightOJ 1197 Help Hanzo
题目链接:点我Amakusa, the evil spiritual leader has captured the beautiful princess Nakururu. The reason behind this is he had a little problem with Hanzo Hattori, the best ninja and the love of Nakururu. Af原创 2017-07-29 11:18:35 · 352 阅读 · 0 评论 -
LightOJ 1213 Fantasy of a Summation
题目链接:点我If you think codes, eat codes then sometimes you may get stressed. In your dreams you may see huge codes, as I have seen once. Here is the code I saw in my dream.#include <stdio.h>int cases, cas原创 2017-07-29 11:05:57 · 358 阅读 · 0 评论 -
LightOJ 1214 Large Division
题目链接:点我Given two integers, a and b, you should check whether a is divisible by b or not. We know that an integer a is divisible by an integer b if and only if there exists an integer c such that a = b原创 2017-07-29 10:50:31 · 273 阅读 · 0 评论 -
LightOJ 1220 Mysterious Bacteria
题目链接:点我Dr. Mob has just discovered a Deathly Bacteria. He named it RC-01. RC-01 has a very strange reproduction system. RC-01 lives exactly x days. Now RC-01 produces exactly p new deadly Bacteria wher原创 2017-07-29 10:42:50 · 311 阅读 · 0 评论 -
LightOJ 1234 Harmonic Number
题目链接:点我In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers:In this problem, you are given n, you have to find Hn.InputInput starts with an integer T (≤原创 2017-07-29 10:32:04 · 448 阅读 · 0 评论 -
LightOJ 1236 Pairs Forming LCM
题目链接:点我Find the result of the following code:long long pairsFormLCM( int n ) { long long res = 0; for( int i = 1; i <= n; i++ ) for( int j = i; j <= n; j++ ) if( lcm(i, j) ==原创 2017-07-29 10:24:28 · 315 阅读 · 0 评论 -
Construct a Matrix FZU - 1911 矩阵快速幂
题目链接:点我 There is a set of matrixes that are constructed subject to the following constraints:1. The matrix is a S(n)×S(n) matrix;2. S(n) is the sum of the first n Fibonacci numbers modulus m,原创 2017-08-23 19:05:17 · 322 阅读 · 0 评论 -
How Many Calls? UVA - 10518 矩阵快速幂
题目链接: 点我题意:给你fibonacci数列怎么求的,然后问你求f(n) = f(n - 1) + f(n - 2)需要多少次调用,并且这个数很大,取模一个进制的数。思路:我们要知道调用次数F(n) = f(n)* 2 - 1这个规律,那么这题就可以解了,矩阵快速幂跑一边即可.代码:#include<cstdio>#include<cstring>#include<iostream>#in原创 2017-08-23 19:10:11 · 313 阅读 · 0 评论 -
M斐波那契数列 HDU - 4549 矩阵快速幂
题目链接 M斐波那契数列F[n]是一种整数数列,它的定义如下:F[0] = aF[1] = bF[n] = F[n-1] * F[n-2] ( n > 1 )现在给出a, b, n,你能求出F[n]的值吗? Input输入包含多组测试数据;每组数据占一行,包含3个整数a, b, n( 0 <= a, b, n <= 10^9 )Output对每组测试数据请输出一个整数F[n],由于F[n]原创 2017-08-23 19:35:38 · 422 阅读 · 0 评论 -
Divisors POJ - 2992
题目链接Your task in this problem is to determine the number of divisors of Cnk. Just for fun -- or do you need any special reason for such a useful computation? InputThe input consists of several instanc原创 2017-09-29 20:54:16 · 701 阅读 · 0 评论 -
Period of an Infinite Binary Expansion POJ - 3358 欧拉函数
题目链接Let {x} = 0.a1a2a3... be the binary representation of the fractional part of a rational number z. Suppose that {x} is periodic then, we can write{x} = 0.a1a2...ar(ar+1ar+2...ar+s)wfor some integers原创 2017-09-28 23:24:13 · 551 阅读 · 0 评论 -
Happy 2006 POJ - 2773 数论
题目链接Two positive integers are said to be relatively prime to each other if the Great Common Divisor (GCD) is 1. For instance, 1, 3, 5, 7, 9...are all relatively prime to 2006.Now your job is easy: for原创 2017-09-28 23:13:44 · 397 阅读 · 0 评论 -
More Divisors ZOJ - 2562 反素数
题目链接Everybody knows that we use decimal notation, i.e. the base of our notation is 10. Historians say that it is so because men have ten fingers. Maybe they are right. However, this is often not very c原创 2017-09-02 13:33:52 · 416 阅读 · 0 评论 -
Primitive Roots POJ - 1284 原根, 欧拉函数
题目链接We say that integer x, 0 < x < p, is a primitive root modulo odd prime p if and only if the set { (x^i mod p) | 1 <= i <= p-1 } is equal to { 1, ..., p-1 }. For example, the consecutive powers of 3原创 2017-09-02 09:20:40 · 439 阅读 · 0 评论 -
数学小知识&总结索引(持续更新)
11、判断组合数C(n,m)的奇偶性有一个我也不知道证明的方法当n&m==m为奇数,反之就是偶数计算几何题目推荐.数学小知识:拉姆齐定理 - 维基百科 : 离散数学老师将过一个一个小例子.六个人中必定有三个人互相认识或者不认识,调和级数求和公式 - 维基百科: Sn=ln(n+1)+C=ln(n)+C−1.0/(n∗2)S_n = ln(n+1) + C = ln(n) + C - 1.0 /原创 2017-08-19 18:50:21 · 494 阅读 · 0 评论 -
number number number hdu 6189 矩阵快速幂
题目链接We define a sequence F:⋅ F0=0,F1=1;⋅ Fn=Fn−1+Fn−2 (n≥2).Give you an integer k, if a positive number n can be expressed byn=Fa1+Fa2+...+Fak where 0≤a1≤a2≤⋯≤ak, this positive number is mjf−good. Ot原创 2017-09-10 19:44:01 · 508 阅读 · 0 评论 -
Coin 2017 西安网络赛 快速幂 + 二项式定理
题目链接Bob has a not even coin, every time he tosses the coin, the probability that the coin’s front face up is qp(qp≤12)qp(qp≤12)pq(pq≤21).qp(qp≤12)\frac{q}{p}(\frac{q}{p} \le \frac{1}{2})原创 2017-09-16 18:45:08 · 395 阅读 · 0 评论 -
Snakes and Ladders LightOJ - 1151 概率dp + 高斯消元
题目链接'Snakes and Ladders' or 'Shap-Ludu' is a game commonly played in Bangladesh. The game is so common that it would be tough to find a person who hasn't played it. But those who haven't played it (unl原创 2017-09-07 19:14:50 · 842 阅读 · 0 评论 -
Function HDU - 6038
[题目链接](http://acm.hdu.edu.cn/showproblem.php?pid=6038)You are given a permutation a from 0 to n−1 and a permutation b from 0 to m−1.Define that the domain of function f is the set of integers from 0 to原创 2017-08-24 10:45:49 · 422 阅读 · 0 评论 -
Balala Power! HDU - 6034 贪心
题目链接Talented Mr.Tang has n strings consisting of only lower case characters. He wants to charge them with Balala Power (he could change each character ranged from a to z into each number ranged from 0原创 2017-08-24 10:05:13 · 509 阅读 · 0 评论 -
ZOJ 3687 The Review Plan I 禁位排列 | 容斥原理
题目链接 Michael takes the Discrete Mathematics course in this semester. Now it's close to the final exam, and he wants to take a complete review of this course.The whole book he needs to review has N chap原创 2017-08-24 09:33:52 · 780 阅读 · 0 评论 -
Connected Graph POJ1737 高精度
题目链接An undirected graph is a set V of vertices and a set of E∈{V*V} edges.An undirected graph is connected if and only if for every pair (u,v) of vertices,u is reachable from v.You are to write a prog原创 2017-08-24 09:06:11 · 321 阅读 · 0 评论 -
Special Special Judge III ZOJ - 3413
题目链接 Because of recent update of ZOJ, some special judges were broken. You're requested to fix the special judge for Problem 9999.In Problem 9999, there is only one case in where the standard output is原创 2017-08-24 08:33:07 · 425 阅读 · 0 评论 -
NUMBER BASE CONVERSION POJ 1220 进制转换模板
题目链接Write a program to convert numbers in one base to numbers in a second base. There are 62 different digits:{ 0-9,A-Z,a-z }HINT: If you make a sequence of base conversions using the output of one c原创 2017-08-23 20:48:41 · 322 阅读 · 0 评论 -
LightOJ 1245 Harmonic Number (II)
题目链接:点我I was trying to solve problem '1234 - Harmonic Number', I wrote the following codelong long H( int n ) { long long res = 0; for( int i = 1; i <= n; i++ ) res = res + n / i; r原创 2017-07-28 23:19:50 · 214 阅读 · 0 评论 -
Goldbach`s Conjecture LightOJ 1259
题目链接:点我Goldbach's conjecture is one of the oldest unsolved problems in number theory and in all of mathematics. It states:Every even integer, greater than 2, can be expressed as the sum of two primes [原创 2017-07-28 23:05:24 · 306 阅读 · 0 评论 -
Contemplation! Algebra UVA - 10655 矩阵快速幂
题目链接:点我题意:给你a + b 和 a * b 让你计算 an a ^{n} + bn b ^{n} 思路:矩阵快速幂. 刚开始看见这个式子我也是懵逼的,后来就想,看看能不能找规律,于是自己手写了几项, 发现还是真的有一部份规律. an a^{n} + bnb^{n} =(an−1 a^{n - 1} + bn−1b^{n - 1}) * ( a + b - a * b ) ,突然发现自己乱写原创 2017-08-18 20:32:58 · 267 阅读 · 0 评论 -
Power of Matrix UVA - 11149(矩阵倍增)
题目链接:点我题意:给你一个矩阵 A, 让你求 A + A2A^{2} + A3A^{3} + A4A^{4} + A5A^{5} + …. AnA^{n},思路:矩阵倍增,那么怎么倍增呢, 令矩阵 S = A + A2A^{2} + A3A^{3} + A4A^{4} + A5A^{5} + … AnA^{n} = A + A2A^{2} + A3A^{3} + A4A^{4} + A5A^{原创 2017-08-18 20:19:56 · 333 阅读 · 0 评论 -
Yet another Number Sequence UVA - 10689 (矩阵快速幂)
题目链接:点我题意:求f(n) mod m 的值,思路:类似与求斐波那契数列(Fibonacci)数列的第n项那样,快速幂即可. 构造递推矩阵为:(1110) \begin{pmatrix} 1 & 1 \\ 1 & 0\end{pmatrix}代码:#include<cstdio>#include<algorithm>#include<cstring>#include<cmath>#原创 2017-08-18 20:07:20 · 313 阅读 · 0 评论 -
Experienced Endeavour UVA - 11551 (矩阵快速幂)
题目链接:点我题意:给定一列数,每个数对应一个变换,变换为原先数列一些位置相加起来的和,问r次变换后的序列是多少.思路:矩阵快速幂,将需要变换的位置变为1, 其他的都为0, 然后快速幂跑R次即可.代码:#include<cstdio>#include<algorithm>#include<cstring>#include<iostream>#include<cmath>using name原创 2017-08-18 20:01:57 · 317 阅读 · 0 评论
分享