简单的算法题
文章平均质量分 59
effcon
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
最大子列和 分治算法与在线处理算法
刚做完题,先把代码放着,有时间在更新 分治算法 #include <iostream> using namespace std; #define maxn (int)10e5+5 int array[maxn]={0}; int main() { int n; int i; int len; cin>>len; for(i=0;...原创 2018-10-11 08:30:31 · 335 阅读 · 0 评论 -
数组元素循环右移问题
一个数组A中存有N(>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(≥0)个位置,即将A中的数据由(A0,A1,⋯AN−1)变换为(AN−M,⋯AN−1,A0,A1, ⋯AN−M−1)(最后M个数循环移至最前面的M个位置)。如果需要考虑程序移动数据的次数尽量少,要如何设计移动的方法? 输入格式: 每个输入包含一个测试用例,第1行输入N(1≤N≤100)和M(≥0);第...原创 2018-09-27 13:41:43 · 219 阅读 · 0 评论 -
打印沙漏
本题要求你写个程序把给定的符号打印成沙漏的形状。例如给定17个“*”,要求按下列格式打印 ***** *** * *** ***** 所谓“沙漏形状”,是指每行输出奇数个符号;各行符号中心对齐;相邻两行符号数差2;符号数先从大到小顺序递减到1,再从小到大顺序递增;首尾符号数相等。 给定任意N个符号,不一定能正好组成一个沙漏。要求打印出的沙漏能用掉尽可能多的符号。 输入格式: 输入在一行给...原创 2018-09-26 17:58:25 · 165 阅读 · 0 评论 -
素数对猜想
让我们定义dn 为:dn=pn+1 −pn,其中pi 是第i个素数。显然有d1 =1,且对于n&gt;1有dn是偶数。“素数对猜想”认为“存在无穷多对相邻且差为2的素数”。 现给定任意正整数N(&lt;10^5 ),请计算不超过N的满足猜想的素数对的个数。 输入格式: 输入在一行给出正整数N。 输出格式: 在一行中输出不超过N的满足猜想的素数对的个数。 输入样例...原创 2018-09-26 18:52:04 · 270 阅读 · 0 评论 -
Have Fun with Numbers
Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number con...原创 2018-09-28 09:42:43 · 153 阅读 · 0 评论 -
Shuffling Machine
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid “inside jobs” where employees collaborate with gambler...原创 2018-09-28 17:54:19 · 501 阅读 · 0 评论
分享