随笔分类 -  题解1

摘要:拿到题目还是先想着用暴力,但是结果超时了,所以不得不优化代码,显然交换一整行,列,比一个一个交换效率要高很多,并且注意到行交换和列交换是独立的,互不影响,所以可以建立行列的索引列表,过程中只交换索引,最后用索引来输出 `#include<stdio.h> include<stdlib.h> incl 阅读全文
posted @ 2025-01-22 21:13 十柒* 阅读(5) 评论(0) 推荐(0) 编辑
摘要:正常思路就是暴力遍历,但是这样容易超时,所以就要优化代码。很容易想到,每种相同字母最终都会替换成一种字母,所以只要把26个字母最后替换成什么字母搞清楚,再用这种替换关系来替换所需字符串就好了。 `#include<stdio.h> include<stdlib.h> include<string.h 阅读全文
posted @ 2025-01-22 21:06 十柒* 阅读(4) 评论(0) 推荐(0) 编辑
摘要:`#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 阅读全文
posted @ 2025-01-22 20:59 十柒* 阅读(12) 评论(0) 推荐(0) 编辑
摘要:把每轮收集到的各个字母数量统计一下,不足m轮的就意味着最少要出少的数目,最后把每个字母最少要出的数量加起来就是答案。 `#include<stdio.h> include<stdlib.h> include<string.h> int main(){ int n,m,t; char a[500]; 阅读全文
posted @ 2025-01-22 20:48 十柒* 阅读(3) 评论(0) 推荐(0) 编辑
摘要:显然10^60是一个很大的数,用long long都爆了,所以可以把每个数当做字符串来收集,而判断单复数只与最后一位有关 `#include<stdio.h> include<stdlib.h> include<string.h> int main(){ int n; char a[67]; sca 阅读全文
posted @ 2025-01-22 20:40 十柒* 阅读(3) 评论(0) 推荐(0) 编辑
摘要:每三次为一个循环,总共循环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 阅读全文
posted @ 2025-01-22 20:36 十柒* 阅读(7) 评论(0) 推荐(0) 编辑
摘要:没什么好说的,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" 阅读全文
posted @ 2025-01-22 20:28 十柒* 阅读(4) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示