摘要: 题解: 此题的关键不在排序,而在于大数字 我们可以用字符串进行存储,比较他们的长度,长度一样时比较他们的大小即可 #include<iostream>using namespace std; int main(){ int n; cin>>n; int ret=0,pre=0; string max 阅读全文
posted @ 2020-02-17 10:05 BlueValentines 阅读(154) 评论(0) 推荐(0)
摘要: 题解: #include<iostream>using namespace std;int ret=0,m_n;void p(int n,double k,int j){ if(k==1){ if(n>=j){ ret++; return; }else{ return; } } for(int i= 阅读全文
posted @ 2020-02-13 10:58 BlueValentines 阅读(150) 评论(0) 推荐(0)
摘要: 题解: 这其实是变相的斐波那契,观察下列等式: //k=2 : 1 2 3 5 8 13 21 34...... //k=3 : 1 2 4 7 13 24 44 81... //k=4 : 1 2 4 8 15 29 56 108... //k=5 : 1 2 4 8 16 31 61 120.. 阅读全文
posted @ 2020-02-11 10:59 BlueValentines 阅读(129) 评论(0) 推荐(0)
摘要: 题解: #include<iostream>#include<cmath>using namespace std; int main(){ int m,n; cin>>m>>n; int a[n],b[m]; int ret=0; int c,c1=0; for(int i=0;i<n;i++){ 阅读全文
posted @ 2020-02-10 11:25 BlueValentines 阅读(146) 评论(0) 推荐(0)
摘要: 题解: 从最后一个输入的数据开始排查,如果说你找到了这个点上面有地毯,那么就直接输出这个值,如果没找到就按照题干的意思输出-1。 #include<iostream>#include<cmath>using namespace std; int main(){ int n; cin>>n; int 阅读全文
posted @ 2020-02-09 11:53 BlueValentines 阅读(128) 评论(0) 推荐(0)
摘要: 题解: 这道题用传统快排(如下所示)的结果就是最后三个点TLE: 如果永远取第一个元素作为枢轴的话,在数组已经有序的情况下每次划分都将得到最坏的结果,时间复杂度退化为O(n^2)。因为其中一个子序列每次都只比原序列少一个元素,该侧的递归深度将达到最大。 #include<iostream>using 阅读全文
posted @ 2020-02-07 12:06 BlueValentines 阅读(158) 评论(0) 推荐(0)
摘要: 题解: 这道题告诉我们:有些题不必死算,可以找规律 #include<stdio.h> int main(){ int n,i;//i为第几组数字,n为总序数 scanf("%d",&n); for(i=1;i<n;i++){ n-=i; if(n<=0){ n+=i; break; } }//n为 阅读全文
posted @ 2020-02-06 10:35 BlueValentines 阅读(126) 评论(0) 推荐(0)
摘要: #include<stdio.h>void move(int n,char a,char b){ printf("将第%d个盘子从%c移动到%c\n",n,a,b); return;} void hanoi(int n,char a,char b,char c){ if(n==1){ move(n, 阅读全文
posted @ 2020-02-05 10:33 BlueValentines 阅读(98) 评论(0) 推荐(0)
摘要: 题解: 原先我想的还是一个一个地输出,但看了一些大佬的写法,发现其实此题很简单 简单的题解: 输入int的时候它不会自动舍去前面的0吗 负的乘以整的不还是负的吗 #include <iostream>using namespace std;int n,k;int main(){ cin >> n; 阅读全文
posted @ 2020-02-04 11:18 BlueValentines 阅读(107) 评论(0) 推荐(0)
摘要: 题解: 在测试数据里有一个是临界值问题,探测范围是闭区间 #include<stdio.h>int main(){ double s,x; //注意:此题所有的变量都是浮点数,说的是实数,不是整数 scanf("%lf %lf",&s,&x); double a=s-x,b=s+x; double 阅读全文
posted @ 2020-02-03 15:51 BlueValentines 阅读(131) 评论(0) 推荐(0)