A. Anastasia and pebbles time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she…
链接:传送门 题意:这个人每次都去公园捡石子,她有两个口袋,每个口袋最多装 k 个石子,公园有 n 种石子,每种石子 w[i] 个,询问最少几天能将石子全部捡完 思路:排个序,尽量每天都多装,如果 k > w[i] ,那就直接将石子全部放入口袋,如果 k < w[i] 那就多次来装. /************************************************************************* > File Name: Codeforces789A.…
PJ考试可能会用到的数学思维题选讲 by Pleiades_Antares 是学弟学妹的讲义--然后一部分题目是我弄的一部分来源于洛谷用户@ 普及组的一些数学思维题,所以可能有点菜咯别怪我 OI中的数学题--你会你就能做,不会做就是真的做不出来QAQ 鲁迅曾说:一入数学深似海,从此AC是路人. 一些会说到的题目:(都是洛谷编号) 这些题目全都是原来NOIP考过的真题喔 1010 1014 1029 1035 1045 1075 1012 1351 2119 ok咱们开始说 第一题,洛谷P1010…
A. Anastasia and pebbles time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she…
Codeforces 题面传送门 & 洛谷题面传送门 首先注意到这个图的特殊性:我们对于所有 \(s_i=s_j\)​ 的 \((i,j)\)​ 之间都连了条边,而字符集大小顶多只有 \(8\)​,因此当 \(n\)​ 比较大时这张图肯定是相当稠密的,故我们猜测这个直径长度肯定也不会太长.事实的确如此,具体来说,对于图上任意两个点 \(i,j\)​,它们之间最短距离的长度肯定不会超过 \(15\)​,具体证明大概就对于每一对字母 \((x,y)\)​,如果存在某两个位置 \(i,i+1\) 满足…
Codeforces 题目传送门 & 洛谷题目传送门 首先直接暴力枚举显然是不现实的,我们不妨换个角度来处理这个问题,考虑这 \(R_i\) 个瓶子中每一瓶被哪些熊在哪一天喝过. 我们考虑对这 \(R_i\) 个瓶子各建立一个 \(q\times n\) 的 01 矩阵,第 \(j\) 行第 \(k\) 列为 \(1\) 表示第 \(k\) 只熊在第 \(j\) 天尝过了这瓶酒,反之第 \(k\) 只熊在第 \(j\) 天尝过了这瓶酒. 那么题目中的条件可表示为: 每一个表格里 \(1\) 的个…
Codeforces 题目传送门 & 洛谷题目传送门 下设 \(n,m\) 同阶. 首先有一个傻子都会的暴力做法,枚举矩形的上.下边界 \(l,r\),考虑集合多重集 \(S=\{y|x\in[l,r],(x,y)\text{为标记点}\}\),也就是所有在第 \(l\) 行与第 \(r\) 行之间所有标记点的列坐标的集合,考虑进一步枚举矩形的左端点 \(x\),那么对于右端点 \(y\),以 \((l,x)\) 为左上角,\((r,y)\) 为右下角的矩形中至少有 \(k\) 个标记点当前仅当…
1003 阶乘后面0的数量 基准时间限制:1 秒 空间限制:131072 KB 分值: 5         难度:1级算法题 n的阶乘后面有多少个0? 6的阶乘 = 1*2*3*4*5*6 = 720,720后面有1个0.   Input 一个数N(1 <= N <= 10^9) Output 输出0的数量 Input示例 5 Output示例 1题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1003编程之…
A. Vladik and Courtesy time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. Afte…
题目:传送门.(需要下载PDF) 题意:t组数据,每组数据给定一个数ni(1 ≤ ni ≤ 10^18),把ni拆成尽可能多的数,要求每个数的素因子只包含2和3,且这些数不能被彼此整除,输出一共能拆成多少个数,并输出这些数. 题解:根据题意ni = 2^a0*3^b0*+2^a1*3^b1+........+2^ax*3^bx,所以我们按照ai升序,bi降序的顺序求出每一个加数,这样会保证这些数不能被彼此整除.首先打表得知3^40会超过long long,3^39不会,先打出3^39的表存到数组…
题目大意:月亮从0到15,15下面是0.循环往复.给出n个数字,如果下一个数字大于第n个数字输出UP,小于输出DOWN,无法确定输出-1. 题目思路:给出0则一定是UP,给出15一定是DOWN,给出其他的一个数字(n==1)无法确定,其他的情况比较后两位. #include<iostream> #include<algorithm> #include<cstring> #include<vector> #include<stdio.h> #inc…
Solution 我又双叒叕去看题解啦$QAQ$, 真的想不到鸭 输入 $a$ 和 $n$ 互质, 所以满足 $a \times i \ mod \ n$ $(0<=i<n)$ 肯定是不重复的 根据这一个性质 , 设 满足条件的子串的开头位置为 $s$ 先不考虑$01$, 仅考虑开头位置上的值 $a*s+b$, 设它为$x$, 则它接下来第 $i$ 位的值为 $x+(i-1)*a$ 若那个位置上的字符为 $0$, 则 $0<=x+(i-1)*a<p$, 反之 $p<=x+(i…
题目描述 给定n,a,b,p,其中n,a互质.定义一个长度为n的01串c[0..n-1],其中c[i]==0当且仅当(ai+b) mod n < p.给定一个长为m的小01串,求出小串在大串中出现了几次. 输入 第一行包含整数n,a,b,p,m(2<=n<=10^9,1<=p,a,b,m<n,1<=m<=10^6).n和a互质.第二行一个长度为m的01串. 输出 一个整数,表示小串在大串中出现了几次 样例输入 9 5 6 4 3 101 样例输出 3 提示 假设我…
传送门:Problem B https://www.cnblogs.com/violet-acmer/p/9739115.html 题意: 找到最小的包含子序列a的序列s,并且序列s是 p -莫干山序列. 题解: 很容易想到 p = max_ai+1,并且a[1]对应着s[1],不然需要在a[1]前加其他数来使的a[1]->某s[i],肯定比不加的序列要长. 遍历a[ ] 数组,分三种情况讨论 ①a[i] > a[i-1] 此种情况下,a[i-1]--a[i]在s中是连续的一段序列,res +…
传送门:Problem A https://www.cnblogs.com/violet-acmer/p/9739115.html 题意: 能否通过横着排或竖着排将 1x p 的小姐姐填满 n x m 的区域内. 题解: 只有当 n*m%p == 0 时才有可能填满,又注意到 p 为质数,故如果 n*m%p == 0, 则 n,m只少有一个是 p 的整倍数. 分两种情况: (1)n*m%p != 0 ,输出 No. (2)n*m%p == 0 ①如果 n%p == 0,可以将 n 分成 n/p…
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2818 题目描述: Given positive integers B and N, find an integer A such that AN is as close as possible to B. (The result A is an approximation to the Nth root of B.) Note that AN may be l…
 Recycling Bottles time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from the…
Money Transfers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n banks in the city where Vasya lives, they are located in a circle, such that any two banks are neighbouring if th…
Problem Description Professor Zhang has a number sequence a1,a2,...,an. However, the sequence is not complete and some elements are missing. Fortunately, Professor Zhang remembers some properties of the sequence: 1. For every i∈{1,2,...,n}, 0≤ai≤100.…
E. Vanya and Field time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vanya decided to walk in the field of size n × n cells. The field contains m apple trees, the i-th apple tree is at the c…
D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's cha…
https://www.hackerrank.com/contests/world-codesprint-6/challenges/bonetrousle 给定一个数n,和k个数,1--k这k个,要求选择b个数,使得这b个数的和等于n. 首先考虑最小值,在1--k中选择前b个数,是最小的,记为mi.最大值,后b个数相加,记为mx 注意到一个东西:如果mi <= n <= mx.那么是绝对可行的.因为mi总能增加1(同时保证满足要求),所以在这个区间里面的,都是可行解. 所以首先从mi开始枚举,…
过程很美妙啊 Problem Description Rikka is a high school girl suffering seriously from Chūnibyō (the age of fourteen would either act like a know-it-all adult, or thinks they have special powers no one else has. You might google it for detailed explanation)…
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5564   根据它的定义是行最小,列最大. 可以证明鞍点是唯一的. 单独考虑每一个元素的贡献,它能成为鞍点的情况有: 1.在这一行中,<= a[i][j]的元素肯定要删除,那么剩下k1个大于他a[i][j]的,当然a[i][j]本身不能删除 2.在这一列中,>= a[i][j]的元素肯定要删除,那么剩下k2个小于a[i][j]的,当然a[i][j]本身不能删除…
/* 参看博客地址:http://blog.csdn.net/oceanlight/article/details/7857713 重点是取完最优的后剩余的rest=n%lcm+lcm;中性价比小的数目num<lcm/性价比小的体积,因为如果大于的话 肯定可以由性价比好的替换. 然后枚举.从体积大的开始枚举次数少. 注意64位 */ #include<stdio.h> #include<string.h> #include<stdlib.h> #define ll…
Online Judge:Luogu,Codeforces Round #592 (Div. 2) C Label:数学,思维题, 枚举 题目描述 某球队一共打了\(n\)场比赛,总得分为\(p\),已知赢一场得\(w\)分,平局一场得\(d\)分,输一场不加分也不减分,问一共赢了几场(x),平局了几场(y),输了几场(z)?如果不存在合法方案输出"-1",如果存在多组可能的方案,任意输出一组(Special Judge). 也就是任求一组符合条件的非负整数三元组\((x,y,z)\)…
http://codeforces.com/problemset/problem/1009/B B. Minimum Ternary String time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a ternary string (it is a string which consists only…
题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0),先从1开始找到已经套好的娃娃层数, 其他是2次操作,还要减去k-1个娃娃是只要套上就可以 详细解释:http://blog.csdn.net/firstlucker/article/details/46671251 */ #include <cstdio> #include <algor…
C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R',…
Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are n commodities produced by the company. For each of them there is exactly one integer in the final report, that denotes correspond…