摘要: 思维: 我们可以发现,nice stairs的长度为1,3,7,15... 不难发现,长度变化每次2+1,而每次长度的nice stairs是等差数列,所以当长度为n时,一共有$\frac{n(n+1)}{2}$个正方形 #include <iostream> using namespace std 阅读全文
posted @ 2022-06-19 10:50 incra 阅读(36) 评论(0) 推荐(0)
摘要: 模拟: 依题意模拟即可。 别忘了把数组开大来! #include <iostream> using namespace std; const int N = 100010; int n; int a[N]; int main () { cin >> n; for (int i = 1;i <= n; 阅读全文
posted @ 2022-06-19 09:59 incra 阅读(28) 评论(0) 推荐(0)
摘要: BFS: 暴力枚举所有情况即可 #include <iostream> #include <queue> using namespace std; int n; string s; string bfs () { queue <string> q; for (int i = 0;i < 26;i++ 阅读全文
posted @ 2022-06-19 09:45 incra 阅读(46) 评论(0) 推荐(0)
摘要: 暴力: 依题意暴力枚举即可 #include <iostream> #include <algorithm> using namespace std; const int N = 1030; int n; int a[N],b[N]; int main () { int T; cin >> T; w 阅读全文
posted @ 2022-06-19 09:04 incra 阅读(33) 评论(0) 推荐(0)
摘要: 并查集: 思路:把所有x或y相同的点合并成一个集合,所需要加的点数就是连通块数量-1。 #include <iostream> using namespace std; const int N = 110; int n; int x[N],y[N],p[N]; int find (int x) { 阅读全文
posted @ 2022-06-19 07:42 incra 阅读(39) 评论(0) 推荐(0)