## (算法入门经典大赛 优先级队列)LA 3135(之前K说明)

A data stream is a real-time, continuous, ordered sequence of items. Some examples include sensor data, Internet traffic, financial tickers, on-line auctions, and transaction logs such as Web usage logs and telephone call records. Likewise, queries o…

## .Uva&amp;LA部分题目代码

1.LA 5694 Adding New Machine 关键词:数据结构,线段树,扫描线(FIFO) #include <algorithm> #include <cstdio> #include <cstring> #include <string> #include <queue> #include <map> #include <set> #include <ctime> #include <cm…

## algorithm@ Sieve of Eratosthenes (素数筛选算法) &amp; Related Problem (Return two prime numbers )

Sieve of Eratosthenes (素数筛选算法) Given a number n, print all primes smaller than or equal to n. It is also given that n is a small number. For example, if n is 10, the output should be “2, 3, 5, 7″. If n is 20, the output should be “2, 3, 5, 7, 11, 13,…

## POJ2739 Sum of Consecutive Prime Numbers(尺取法）

POJ2739 Sum of Consecutive Prime Numbers 题目大意:给出一个整数,如果有一段连续的素数之和等于该数,即满足要求,求出这种连续的素数的个数 水题:艾氏筛法打表+尺取法区间推进,0ms水过(注意循环的终止条件) #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <ctime> #include &l…

## Project Euler：Problem 87 Prime power triples

The smallest number expressible as the sum of a prime square, prime cube, and prime fourth power is 28. In fact, there are exactly four numbers below fifty that can be expressed in such a way: 28 = 22 + 23 + 24 33 = 32 + 23 + 24 49 = 52 + 23 + 24 47…

## 【Poj3126】【BNUOJ3245】Prime Path

http://poj.org/problem?id=3126 https://www.bnuoj.com/v3/problem_show.php?pid=3245 题目鬼图 刚开始看到题目的图觉得这题会很鬼,然后看题,发现是水题... 线性筛预处理素数→BFS+记录深度 or 迭代加深 or 分层BFS // <3126.cpp> - 11/01/16 17:31:53 // This file is made by YJinpeng,created by XuYike's black tec…

## [ACM] POJ 2689 Prime Distance (筛选范围大素数）

Prime Distance Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12811   Accepted: 3420 Description The branch of mathematics called number theory is about properties of numbers. One of the areas that has captured the interest of number th…

## HDU 5919 - Sequence II (2016CCPC长春) 主席树 （区间第K小+区间不同值个数）

HDU 5919 题意: 动态处理一个序列的区间问题,对于一个给定序列,每次输入区间的左端点和右端点,输出这个区间中:每个数字第一次出现的位子留下, 输出这些位子中最中间的那个,就是(len+1)/2那个. 思路: 主席树操作,这里的思路是从n到1开始建树.其他就是主席树查询区间第K小,计算区间不同值个数. #include <algorithm> #include <iterator> #include <iostream> #include <cstring&…

## HDU 3823 Prime Friend（线性欧拉筛+打表）

Besides the ordinary Boy Friend and Girl Friend, here we define a more academic kind of friend: Prime Friend. We call a nonnegative integer A is the integer B’s Prime Friend when the sum of A and B is a prime. So an integer has many prime friends, fo…

## [codeforces438E]The Child and Binary Tree

[codeforces438E]The Child and Binary Tree 试题描述 Our child likes computer science very much, especially he likes binary trees. Consider the sequence of n distinct positive integers: $$c_1, c_2, \cdots , c_n$$. The child calls a vertex-weighted rooted b…

## HDU 4569 Special equations(取模)

Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4569 Description Let f(x) = a nx n +...+ a 1x +a 0, in which a i (0 <= i <= n) are all known integers. We call f(x) 0 (mod…

## hdu1000,hdu1001,hdu1002,hdu1003

hdu1000 仅仅是为了纪念 #include <cstdio> int main() { int a,b; while (scanf("%d%d",&a,&b)!=EOF) { printf("%d\n",a+b); } ; } hdu1001 题目说n*(n+1)/2 不不会爆 但是没和你说n*(n+1)不会爆 用下面这个小方法解决  见代码 #include <iostream> int n; int main() {…

## 1220 - Mysterious Bacteria--LightOj1220 (gcd)

http://lightoj.com/volume_showproblem.php?problem=1220 题目大意: 给你一个x,求出满足 x=b^p, p最大是几. 分析:x=p1^a1*p2^a2*...*pn^an; p最大是gcd(a1,a2,...,an). ///他该诉你x,b,p都是整数,所以x,b有可能是负数.当x是负数时,p不能是偶数. #include<stdio.h> #include<string.h> #include<stdlib.h>…

## 1236 - Pairs Forming LCM -- LightOj1236 (LCM)

http://lightoj.com/volume_showproblem.php?problem=1236 题目大意: 给你一个数n,让你求1到n之间的数(a,b && a<=b)两个数的最小公倍数等于n有多少对这样的ab. 分析都写在图片上了,费了我好大的事呢 ac代码 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> #inclu…

## 1341 - Aladdin and the Flying Carpet ---light oj (唯一分解定理+素数筛选)

http://lightoj.com/volume_showproblem.php?problem=1341 题目大意: 给你矩形的面积(矩形的边长都是正整数),让你求最小的边大于等于b的矩形的个数. 什么叫唯一分解定理:算术基本定理可表述为:任何一个大于1的自然数 N,如果N不为质数,那么N可以唯一分解成有限个质数的乘积N=P1a1P2a2P3a3......Pnan,这里P1<P2<P3......<Pn均为质数,其中指数ai是正整数.这样的分解称为 N 的标准分解式 我们求出n的因…

## BZOJ 2440 【中山市选2011】 完全平方数

Description 小 X 自幼就很喜欢数.但奇怪的是,他十分讨厌完全平方数.他觉得这些数看起来很令人难受.由此,他也讨厌所有是完全平方数的正整数倍的数.然而这丝毫不影响他对其他数的热爱. 这天是小X的生日,小 W 想送一个数给他作为生日礼物.当然他不能送一个小X讨厌的数.他列出了所有小X不讨厌的数,然后选取了第 K个数送给了小X.小X很开心地收下了. 然而现在小 W 却记不起送给小X的是哪个数了.你能帮他一下吗? Input 包含多组测试数据.文件第一行有一个整数 T,表示测试数据的组数.…