- 博客(14)
- 收藏
- 关注
原创 再战斐波那契
再战斐波那契小z 学会了斐波那契和 gcd 后,老师又给他出了个难题,求第N个和第M个斐波那契数的最大公约数,这可难倒了小z ,不过在小z 的再三请求下,老师又告诉他了个条件,gcd(N,M)∈[1,90]。可是,笨拙的小z 还是不会,于是请求你帮他解答这个问题。输入格式输入包括 T 组,T∈[1,10].接下来 T 行,每行两个整数 N,M, 表示斐波那契的第 N 项和第 M 项,(N...
2020-04-25 09:45:51
205
原创 Sorting It All Out
Sorting It All OutAn ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest. For example, the sorted seq...
2019-07-28 18:42:19
404
原创 Arbitrage
ArbitrageArbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buys ...
2019-07-28 18:34:52
383
原创 Binary Tree
Binary TreeBackgroundBinary trees are a common data structure in computer science. In this problem we will look at an infinite binary tree where the nodes contain a pair of integers. The tree is con...
2019-07-28 18:26:33
325
原创 恐怖的怪物
恐怖的怪物一天早上,Dicer一觉醒来,发现自己来到了MineCraft的世界里面,身为MineCraft游戏爱好者的他欣喜不已,于是他在地下挖了一片长方体的空间作为秘密基地,可是他发现光照亮度小于等于7时,会有恐怖的怪物出现,并且他通过查阅资料发现光源方块产生光照每一米(方格)衰减1光照等级。此规律在坐标轴的3个方向上(东西、南北、上下)均成立。换句话来说,对角线方向的光照衰减依照“曼哈顿距...
2019-07-27 21:42:38
392
原创 Points in rectangle
Points in rectangle在二维平面中有一个矩形,它的四个坐标点分别为(0,a),(a,0),(n,n−a),(n−a,n)。你现在有m个点,现在你想知道有多少个点是在这个矩形内的(边上的也算)。输入格式第一行输入n,a(1≤a<n≤103)。第二行一个正整数m(1≤m≤103),代表你拥有的点的个数,接下来m行,每行一个点的坐标xi,yi(1≤xi,yi≤103)。输...
2019-07-27 16:54:39
468
原创 Numbers of interval
Numbers of interval现在有一个数组,请计算有多少的区间l,r满足 ∑ri=lai≥k.输入格式第一行输入n,k(1≤n,k≤106).接下来输入n个数,第i个数为ai(1≤ai≤103).输出格式输出满足条件的区间个数input3 52 3 5output4感慨:这道题是一道比赛题,刚开始做的时候脑子抽了,竟然给他排了一下序,果断错了,我当时一脸懵逼,...
2019-07-27 16:42:45
498
原创 Watering Grass
Watering Grassn sprinklers are installed in a horizontal strip of grass l meters long and w meters wide. Each sprinkler is installed at the horizontal center line of the strip. For each sprinkler we ...
2019-07-22 08:36:42
319
原创 Maximum Sum
Maximum SumA problem that is simple to solve in one dimension is often much more difficult to solve in more than one dimension. Consider satisfying a boolean expression in conjunctive normal form in ...
2019-07-22 08:36:07
282
原创 Find The Multiple
Find The MultipleGiven a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater ...
2019-07-22 08:35:32
268
原创 Addition Chains
Addition ChainsAn addition chain for n is an integer sequence <a0, a1,a2,…,am> with the following four properties:a0 = 1am = na0 < a1 < a2 < … < am-1 < amFor each k (1 <= ...
2019-07-21 19:19:50
737
原创 Sticks
SticksGeorge took sticks of the same length and cut them randomly until all parts became at most 50 units long. Nowhewantstoreturnstickstotheoriginalstate,butheforgothowmanystickshehadoriginally and ...
2019-07-21 18:47:42
408
原创 Eight
EightThe 15-puzzle has been around for over 100 years; even if you don’t know it by that name, you’ve seen it. It is constructed with 15 sliding tiles, each with a number from 1 to 15 on it, and all ...
2019-07-21 18:36:53
295
原创 超级密码
超级密码Ignatius花了一个星期的时间终于找到了传说中的宝藏,宝藏被放在一个房间里,房间的门用密码锁起来了,在门旁边的墙上有一些关于密码的提示信息: 密码是一个C进制的数,并且只能由给定的M个数字构成,同时密码是一个给定十进制整数N(0<=N<=5000)的正整数倍(如果存在多个满足条件的数,那么最小的那个就是密码),如果这样的密码存在,那么当你输入它以后门将打开,如果不存
2019-06-03 17:45:19
1211
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人