随笔分类 - 数组
摘要:题目传送门 一、思路总结 需要用二维数组来存储幻方。 因为是奇数,那么中间的位置可以描述为 因为每次都是在上一次的位置上进行变化,所以,对于每次操作时,必须知道上一次的位置。 二、完整代码 #include <bits/stdc++.h> using namespace std;
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 15; char a[N][N];//原始图案 char c[N][N];//目标图案 char t[N][N];//转换后的图案 char t2[N][N]; int
阅读全文
摘要:题目传送门 本题目是的逆运算,计入的是压缩码,输出的是字符矩阵。 #include <bits/stdc++.h> using namespace std; const int N = 210; string a[N]; //注意这里的是字符串数组! int sum; int main
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; int n; //汉字点阵的长和宽 int num; //输出1还是0呢?默认是0 int m; //每次输入的值是几个 int k; //已经处理完的数字个数 int main() { cin
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 110; int a[N][N]; int main() { int n, m, k; //n*n的方阵,m 个火把和 k 个萤石 cin >> n >> m >> k
阅读全文
摘要:题目传送门 总结 1、递推的初始条件 if (j == 0 || j == i) a[i][j] = 1; 2、递推式 a[i][j] = a[i - 1][j - 1] + a[i - 1][j]; #include <bits/stdc++.h> using namespace std; con
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 10; int a[N][N]; //右下左上,顺序不能反,因为本题的蛇形是顺时针方向 int dx[] = {0, 1, 0, -1}; int dy[] = {1,
阅读全文
摘要:题目传送门 总结: 1、桶记录状态,取反 2、类型的强制转换。 #include<bits/stdc++.h> using namespace std; int const N = 2000010; bool b[N]; //灯的状态 double a; //1-1000的实数 int n; //操
阅读全文
摘要:题目传送门 总结: 1、桶,还是用桶,这次桶存的是三层循环遍历出来的所有可能点数和。记录每个点数和出现多少次! 2、然后一次遍历,找出最大的是哪个,最大的那个不要某个数字出现的最多次数,而是要是哪个数字,这个要注意。 #include <bits/stdc++.h> using namespace
阅读全文
摘要:题目传送门 一、两层暴力循环法 #include <bits/stdc++.h> using namespace std; const int N = 3010; const int INF = 0x3f3f3f3f; typedef long long LL; int a[N]; LL MIN =
阅读全文
摘要:题目传送门 一、思路总结 前方有坑!需要理解 ,但只算一次的道理。 数组+桶记录使用过。 二、完整代码 #include <bits/stdc++.h> using namespace std; // 这题30分的一般都是没有去重……1+4=5和2+3=5算同一个……
阅读全文
摘要:题目传送门 总结 1、用桶计数,适合数量不多的场景,比如本题,就是记录 2、考查数位分离 #include <bits/stdc++.h> using namespace std; const int N = 11; int a[N]; int main() { int m, n
阅读全文
摘要:题目传送门 一、思路总结 奖票号码最多是个,可以用一个小的数组来模拟哪个号是中奖号码,这是计数的一个常用办法,需要同学们掌握。 如何知道小明买的每组号码中了几个号呢?需要一个计数的办法,一边读取号码,一边判断中了几个号。 中个号是等奖,中个号是等奖... 中个号
阅读全文
摘要:题目传递门 一、思路总结 常量数组是解题的关键。 先打印行,再打印列是亘古不变的真理。但这里又出来一个遍历数字,如果是数字、行、列三层循环,打印出来就是竖着的。如果是行、数字、列就是正确的啦~ 一个数字是位,如果打印的是第个,第列,就是,因为下标是从开始,所
阅读全文