![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
题解
weixin_43244265
这个作者很懒,什么都没留下…
展开
-
洛谷 P1255 数楼梯
题目描述楼梯有 N 阶,上楼可以一步上一阶,也可以一步上二阶。编一个程序,计算共有多少种不同的走法。输入格式一个数字,楼梯数。输出格式输出走的方式总数。输入输出样例输入 #1复制4输出 #1复制5说明/提示对于 60% 的数据,N≤50;对于 100% 的数据,N≤5000。思路:这个题的关键不在题目上,而在数据。题目就是个简单的斐波那契数列,但我们看到数据会发现这个结果根本存不下,必须用高精度存储(用数据存储数据的每一位,例如12345678存为a[]={1,2,3,原创 2020-10-11 22:34:11 · 400 阅读 · 0 评论 -
十一届蓝桥杯省赛模拟摆动序列(DP)
如果一个序列的奇数项都比前一项大,偶数项都比前一项小,则称为一个摆动序列。即 a[2i]<a[2i-1], a[2i+1]>a[2i]。 小明想知道,长度为 m,每个数都是 1 到 n 之间的正整数的摆动序列一共有多少个。输入格式输入一行包含两个整数 m,n。输出格式输出一个整数,表示答案。答案可能很大,请输出答案除以10000的余数。样例输入3 4样例输出14样...原创 2020-04-19 14:32:33 · 306 阅读 · 1 评论 -
Codeforces Round #623 (Div. 2)C. Restoring Permutation
You are given a sequence b1,b2,…,bn. Find the lexicographically minimal permutation a1,a2,…,a2n such that bi=min(a2i−1,a2i), or determine that it is impossible.InputEach test contains one or more te...原创 2020-02-26 21:41:23 · 290 阅读 · 0 评论 -
Codeforces Round #624 (Div. 3)C. Perform the Combo
You want to perform the combo on your opponent in one popular fighting game. The combo is the string s consisting of n lowercase Latin letters. To perform the combo, you have to press all buttons in t...原创 2020-02-25 18:12:56 · 257 阅读 · 0 评论 -
Codeforces Round #624 (Div. 3)B. WeirdSort
You are also given a set of distinct positions p1,p2,…,pm, where 1≤pi<n. The position pi means that you can swap elements a[pi] and a[pi+1]. You can apply this operation any number of times for eac...原创 2020-02-25 12:02:12 · 113 阅读 · 0 评论 -
Codeforces 219C Color Stripe
A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of...原创 2020-02-23 13:18:28 · 208 阅读 · 0 评论 -
Codeforces134Div.2-C(并查集)
Bajtek is learning to skate on ice. He’s a beginner, so his only mode of transportation is pushing off from a snow drift to the north, east, south or west and sliding until he lands in another snow dr...原创 2020-02-22 23:55:44 · 183 阅读 · 0 评论 -
uva 11237 - Halloween treats(鸽笼原理)
题意:有c个小孩要到邻居家去要糖果,有n户邻居,每户邻居只会提供固定数量的糖果,熊孩子们为了不发生冲突,决定将取来的糖果平均分配,问说取那几家邻居的糖果可以做到平均分配,注意n ≥ c思路:因为n<m,所以m个前缀和分别对孩子数(n)求余,至少有两个余数一样的一组(鸽笼原理),这两组的差肯定是n的倍数,输出两个前缀和序号之间的数就可以。AC代码:#include<iostream...原创 2020-02-22 20:09:31 · 104 阅读 · 0 评论 -
UVA_10664_Luggage(水题)
Peter and his friends are on holiday, so they have decided to make a trip by car to know the north ofSpain. They are seven people and they think that two cars are enough for their luggage.It’s time ...原创 2020-02-20 17:23:09 · 299 阅读 · 0 评论 -
UVA - 1404 Prime k-tuple【筛素数】
{p1, . . . , pk : p1 < p2 < . . . < pk} is called a prime k-tuple of distance s if p1, p2, . . . , pk are consecutiveprime numbers and pk − p1 = s. For example, with k = 4, s = 8, {11, 13, 1...原创 2020-02-19 17:17:44 · 134 阅读 · 0 评论 -
UVA 10236 - The Fibonacci Primes(斐波那契素数)
The Fibonacci number sequence is 1, 1, 2, 3, 5, 8, 13 and so on. You can see that except the first twonumbers the others are summation of their previous two numbers. A Fibonacci Prime is a Fibonacci...原创 2020-02-19 16:37:39 · 170 阅读 · 0 评论 -
UVA10689-Yet another Number Sequence(矩阵快速幂)
Let’s define another number sequence, given by the following function:f(0) = af(1) = bf(n) = f(n − 1) + f(n − 2), n > 1When a = 0 and b = 1, this sequence gives the Fibonacci Sequence. Changing...原创 2020-02-17 17:14:21 · 182 阅读 · 0 评论 -
UVA701 LA5637 The Archeologists' Dilemma
An archeologist seeking proof of the presence of extraterrestrials in the Earth’s past, stumbles upon apartially destroyed wall containing strange chains of numbers. The left-hand part of these lines...原创 2020-02-11 15:52:56 · 170 阅读 · 0 评论 -
UVA 10515 - Powers Et Al
Finding the exponent of any number can be very troublesome as it grows exponentially. But in thisproblem you will have to do a very simple task. Given two non-negative numbers m and n, you willhave ...原创 2020-02-08 16:46:34 · 154 阅读 · 0 评论 -
POJ 1320 Street Numbers(佩尔方程)
DescriptionA computer programmer lives in a street with houses numbered consecutively (from 1) down one side of the street. Every evening she walks her dog by leaving her house and randomly turning l...原创 2020-02-07 15:07:09 · 129 阅读 · 0 评论 -
Codeforces C. Yet Another Walking Robot(2月5日)
There is a robot on a coordinate plane. Initially, the robot is located at the point (0,0). Its path is described as a string s of length n consisting of characters ‘L’, ‘R’, ‘U’, ‘D’.Each of these c...原创 2020-02-05 17:00:20 · 239 阅读 · 0 评论 -
UVA 10110(开关)
There is man named ”mabu” for switching on-off light in our University. He switches on-off the lightsin a corridor. Every bulb has its own toggle switch. That is, if it is pressed then the bulb turns...原创 2020-02-05 14:01:09 · 151 阅读 · 0 评论 -
POJ 1218 THE DRUNK JAILER(开关问题)
Description一个监狱看守员喝醉了酒,于是把监狱每扇门都打开(假设有n扇门);然后再从1号门开始,隔一扇关一个门(把2的倍数的门关掉);接着再从1号门开始,隔2扇操作一个门(操作3的倍数的门,原来是开的关掉,关着的则打开)。这样一直操作到n的倍数,问最后有多少扇门是打开的。这个也可以叫关灯问题:有n个灯,分别由n个开关控制,拨一下开关则可以改变灯的状态(开->关 关->开)。...转载 2020-02-05 12:55:39 · 170 阅读 · 0 评论 -
2.3训练日记
昨天谷歌终于给力一回了,让我打了个完整得CF,虽然依旧得菜但起码好过进不去得烦躁,昨天过了两个题,应该是掉分了(我也不知道掉多少,今天网站又进不去了。。。。),第三题挂得不冤,真没思路,换了好多种方法都行不通,前两个因为漏掉了条件错了一发,因为手滑把大于小于号写反了错了一发,实在不应该,这麽久没打比赛了过程中还是有点慌,打出来没有平时一遍遍验得耐心,就想早点交早点过,出了很多低级错误。以后得训练中...原创 2020-02-03 22:46:42 · 213 阅读 · 0 评论 -
UVA10090 Marbles(扩展欧几里得)
I have some (say, n) marbles (small glass balls) and I am going to buy some boxes to store them. Theboxes are of two types:T ype 1: each box costs c1 Taka and can hold exactly n1 marblesT ype 2: ea...原创 2020-02-03 22:25:37 · 177 阅读 · 0 评论 -
HDU 1299 Diophantus of Alexandria
Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first mathematicians to study equations where variables were restricted to integral values. In honor of him,...原创 2020-02-02 21:59:30 · 1076 阅读 · 0 评论 -
HDU 1098 Ignatius's puzzle
Ignatius is poor at math,he falls across a puzzle problem,so he has no choice but to appeal to Eddy. this problem describes that:f(x)=5x13+13*x5+ka*x,input a nonegative integer k(k<10000),to find t...原创 2020-02-02 16:31:53 · 136 阅读 · 0 评论 -
Fast Fourier Transform Gym
Pavel had two positive integers a and b. He found their sum s and greatest common divisor g, and forgot a and b after that. Help him to restore the original numbers.InputA single line contains two i...原创 2020-01-31 21:09:01 · 153 阅读 · 0 评论 -
CodeForces 75 C.Modified GCD
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it’s an easy task to calculate the GCD between two positive integers.A common divisor for two positive n...原创 2020-01-31 20:59:49 · 191 阅读 · 0 评论 -
CodeForces 7 C. Line(扩展欧几里得)
A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from - 5·1018 to 5·1018 inclusive, or to find out that s...原创 2020-01-30 17:50:56 · 113 阅读 · 0 评论 -
codeforces 630KIndivisibility(容斥原理)
IT City company developing computer games invented a new way to reward its employees. After a new game release users start buying it actively, and the company tracks the number of sales with precision...原创 2020-01-29 23:14:26 · 120 阅读 · 0 评论 -
fzu 1752(欧拉降幂模板题!)
Given A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,C<=1000000000,1<=B<=10^1000000).InputThere are multiply testcases. Each testcase, there is one line contains thre...原创 2020-01-28 15:40:45 · 181 阅读 · 0 评论 -
Codeforces 347C Alice and Bob
It is so boring in the summer holiday, isn’t it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to ...原创 2020-01-27 12:01:10 · 185 阅读 · 0 评论 -
HDU6441(费马大定理,勾股定理)
people in USSS love math very much, and there is a famous math problem .give you two integers nn,aa,you are required to find 22 integers bb,cc such that anan+bn=cnbn=cn.Inputone line contains one i...原创 2020-01-20 22:41:50 · 148 阅读 · 0 评论 -
Deadline(codeforces)
Adilbek was assigned to a special project. For Adilbek it means that he has nn days to run a special program and provide its results. But there is a problem: the program needs to run for dd days to ca...原创 2020-01-16 20:26:37 · 316 阅读 · 0 评论 -
HDU - 1796 How many integers can you find
Now you get a number N, and a M-integers set, you should find out how many integers which are small than N, that they can divided exactly by any integers in the set. For example, N=12, and M-integer s...原创 2020-01-16 16:09:21 · 197 阅读 · 0 评论 -
HDU - 3307 Description has only two Sentences
a n = X*a n-1 + Y and Y mod (X-1) = 0.Your task is to calculate the smallest positive integer k that a k mod a 0 = 0.InputEach line will contain only three integers X, Y, a 0 ( 1 < X < 2 31, ...原创 2020-01-16 16:00:16 · 156 阅读 · 0 评论 -
HDU - 2824 The Euler function
The Euler function phi is an important kind of function in number theory, (n) represents the amount of the numbers which are smaller than n and coprime to n, and this function has a lot of beautiful c...原创 2020-01-16 15:32:44 · 150 阅读 · 0 评论 -
HDU - 2654 Become A Hero
Lemon wants to be a hero since he was a child. Recently he is reading a book called “Where Is Hero From” written by ZTY. After reading the book, Lemon sends a letter to ZTY. Soon he recieves a reply....原创 2020-01-16 15:23:27 · 173 阅读 · 0 评论 -
hdu2588 GCD
The greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written (a,b),is the largest divisor common to a and b,For example,(1,2)=1,(12,18)=6.(a,b) can be easily found by the E...原创 2020-01-16 15:02:02 · 129 阅读 · 0 评论 -
HDU - 1787 GCD Again
Do you have spent some time to think and try to solve those unsolved problem after one ACM contest?No? Oh, you must do this when you want to become a “Big Cattle”.Now you will find that this problem...原创 2020-01-15 22:02:01 · 132 阅读 · 0 评论 -
HDU1395
2^x mod n = 1Give a number n, find the minimum x(x>0) that satisfies 2^x mod n = 1.InputOne positive integer on each line, the value of n.OutputIf the minimum x exists, print a line with 2^x m...原创 2020-01-13 20:49:02 · 110 阅读 · 0 评论 -
HDU - 2866 Special Prime
Give you a prime number p, if you could find some natural number (0 is not inclusive) n and m, satisfy the following expression:We call this p a “Special Prime”.AekdyCoin want you to tell him the n...原创 2019-12-24 21:18:39 · 99 阅读 · 0 评论 -
HDU5019
In mathematics, the greatest common divisor (gcd), also known as the greatest common factor (gcf), highest common factor (hcf), or greatest common measure (gcm), of two or more integers (when at least...原创 2019-12-23 23:40:17 · 87 阅读 · 0 评论 -
HDU - 2619 Love you Ten thousand years
Love you Ten thousand years------Earth’s rotation is a day that is the representative of a day I love you. True love, there is no limit and no defects. Earth’s revolution once a year, it is on behalf ...原创 2019-12-23 21:45:43 · 204 阅读 · 0 评论