数论
骓不逝兮
如果不努力,你还能干嘛
展开
-
包子凑数
小明几乎每天早晨都会在一家包子铺吃早餐。他发现这家包子铺有N种蒸笼,其中第i种蒸笼恰好能放Ai个包子。每种蒸笼都有非常多笼,可以认为是无限笼。每当有顾客想买X个包子,卖包子的大叔就会迅速选出若干笼包子来,使得这若干笼中恰好一共有X个包子。比如一共有3种蒸笼,分别能放3、4和5个包子。当顾客想买11个包子时,大叔就会选2笼3个的再加1笼5个的(也可能选出1笼3个的再加2笼4个的)。当然有时包子大...原创 2019-03-20 23:09:53 · 128 阅读 · 0 评论 -
分解质因子
Counting Divisors In mathematics, the function d(n) denotes the number of divisors of positive integer n. For example, d(12)=6 because 1,2,3,4,6,12 are all 12’s divisors. In this problem, given ...转载 2017-08-21 20:58:06 · 277 阅读 · 0 评论 -
筛选法(质数)
Vasya and Petya’s GameVasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the number.Petya can ask questions like: “Is the unknown number原创 2017-08-21 10:23:21 · 410 阅读 · 0 评论 -
Codeforces 798C Mike and GCD problem
Mike and gcd problemMike has a sequence A = [a1, a2, …, an] of length n. He considers the sequence B = [b1, b2, …, bn] beautiful if the gcd of all its elements is bigger than 1, i.e. .Mike wants to cha原创 2017-08-27 19:15:02 · 217 阅读 · 0 评论 -
Dijkstra算法和Floyd算法概述
Dijkstra算法(适用于 单源最短路问题。且没有负路权。)1.定义概览Dijkstra(迪杰斯特拉)算法是典型的单源最短路径算法,用于计算一个节点到其他所有节点的最短路径。主要特点是以起始点为中心向外层层扩展,直到扩展到终点为止。Dijkstra算法是很有代表性的最短路径算法,在很多专业课程中都作为基本内容有详细的介绍,如数据结构,图论,运筹学等等。注意该算法要求图中不存在负权边。问题描述:在无原创 2017-08-25 09:39:30 · 310 阅读 · 0 评论 -
CodeForces-707c[数学构造]
Pythagorean TriplesKatya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can con原创 2017-08-25 10:05:03 · 242 阅读 · 0 评论 -
质数
Dima and Lisa Dima loves representing an odd number as the sum of multiple primes, and Lisa loves it when there are at most three primes. Help them to represent the given number as the sum of at most t原创 2017-08-18 20:46:25 · 209 阅读 · 0 评论 -
质因数分解
Soldier and Number Game Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possib原创 2017-08-18 19:58:38 · 312 阅读 · 0 评论 -
数论
数论https://www.zybuluo.com/wzq/note/4540951.最大公约数gcd(辗转相除法:)gcd(10,4)=gcd(4,2)=gcd(2,0)=2int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b);}2.最小公倍数lcmlcm(10,4)=10/2*4=20;int lcm(int a,转载 2017-08-15 16:19:33 · 223 阅读 · 0 评论