01 2025 档案
摘要:往返2x次可以看成到对岸2x次,也可以理解为2x只青蛙同时过河,所以每一个y区间石头高度和要>=2x,想到这一步后就解决了,只需要用双指针找出满足条件的最小的y区间了 `#include<stdio.h> include<stdlib.h> include<string.h> include<bit
阅读全文
摘要:这题用二分答案和贪心思想,为了让前面的人尽可能少的抄写,就从后往前分配任务,用贪心思想,先尽量分配任务,直到超过检验的x再分配给下一个人,最后判断人数是否满足条件,最后输出的时候也逆序输出就行了 `#include<stdio.h> include<stdlib.h> include<string.
阅读全文
摘要:显然用二分答案,重点就是check函数怎么写了,用x来表示套牌数,所以x要满足每一个x-a<=b,并且所有x-a的和要<=m.最后结果一定要开long long `#include<stdio.h> include<stdlib.h> include<string.h> include<bits/s
阅读全文
摘要:普通的二分答案,也没什么好说的 `#include<stdio.h> include<stdlib.h> include<string.h> include<bits/stdc++.h> using namespace std; struct bian{ int h; int w; }; int c
阅读全文
摘要:先将数列排序,A-B=C可以看成A=B+C,只要用二分把A的首位和末尾找到,A的个数就是差值+1,最后把每个数都求一遍就是答案了 `#include<stdio.h> include<stdlib.h> include<string.h> include<bits/stdc++.h> using n
阅读全文
摘要:就是基础的二分,没什么好说的 `#include<stdio.h> include<stdlib.h> include<string.h> int seek(int n,int *lst,int x){ int l=0,r=n-1; while(l<=r){ int m=(l+r)/2; if(ls
阅读全文
摘要:拿到题目还是先想着用暴力,但是结果超时了,所以不得不优化代码,显然交换一整行,列,比一个一个交换效率要高很多,并且注意到行交换和列交换是独立的,互不影响,所以可以建立行列的索引列表,过程中只交换索引,最后用索引来输出 `#include<stdio.h> include<stdlib.h> incl
阅读全文
摘要:正常思路就是暴力遍历,但是这样容易超时,所以就要优化代码。很容易想到,每种相同字母最终都会替换成一种字母,所以只要把26个字母最后替换成什么字母搞清楚,再用这种替换关系来替换所需字符串就好了。 `#include<stdio.h> include<stdlib.h> include<string.h
阅读全文
摘要:`#include<stdio.h> include<stdlib.h> include<string.h> int main(){ int n,m,k,sum=0,n1,m1; scanf("%d %d %d",&n,&m,&k); if(n%20){ n1=n/2; } else{ n1=n/2
阅读全文
摘要:把每轮收集到的各个字母数量统计一下,不足m轮的就意味着最少要出少的数目,最后把每个字母最少要出的数量加起来就是答案。 `#include<stdio.h> include<stdlib.h> include<string.h> int main(){ int n,m,t; char a[500];
阅读全文
摘要:显然10^60是一个很大的数,用long long都爆了,所以可以把每个数当做字符串来收集,而判断单复数只与最后一位有关 `#include<stdio.h> include<stdlib.h> include<string.h> int main(){ int n; char a[67]; sca
阅读全文
摘要:每三次为一个循环,总共循环N次。 每个小循环中用i来代表次数,f来判断适合符合题意,word1[3]={'y','e','s'},word2[3]={'Y','E','S'},用a[j]!=word1[j]&&a[j]!=word2[j]来判断当前字母是否符合题意,不符合则f=0(f每次循环初始为1
阅读全文
摘要:没什么好说的,for循环遍历而已 `#include<stdio.h> include<stdlib.h> int main(){ int n; scanf("%d",&n); printf("L"); for(int i=0;i<n;i++){ printf("o"); } printf("ng"
阅读全文