ICode9

精准搜索请尝试: 精确搜索
  • Codeforces Round #812 (Div. 2)2022-08-07 13:30:23

    A 这竟然是我场上唯一一道没1A的题,蚌。 注意初值问题。 #include <cstdio> #include <algorithm> #include <cstring> inline int min(const int x, const int y) {return x < y ? x : y;} inline int max(const int x, const int y) {return x > y ? x : y;} int a[10];

  • 洛谷P2249 【深基13.例1】查找(二分+结构体)2022-08-05 10:02:11

    在实中夏令营上做的题 原题 AC代码 由于要求给出数字第一次出现位置 纯二分是不行的 查出这个数再一步步向前查找会wa一个点tle一个点 所以我干脆在输入时使用结构体把每个数第一次出现位置记下来,到时候线性查找 此思路AC(看你谷几个热门题解都没有涉及结构体,干脆自己发一篇 1 #i

  • string不能用scanf输入2022-08-02 09:31:33

    为了准备中考有半年多没有编程,现在恢复功力时明显手生 今天我在复习排序时遇见了一道题 洛谷P1781 题目描述 地球历公元 6036 年,全宇宙准备竞选一个最贤能的人当总统,共有 n 个非凡拔尖的人竞选总统,现在票数已经统计完毕,请你算出谁能够当上总统。 输入格式 第一行为一个整数 n,代

  • KMP2022-07-31 02:00:37

    https://www.luogu.com.cn/problem/P3375 获得next数组(最长公共前后缀) 用类似的方法获得进行kmp操作 每次匹配成功匹配下一个时 有(j=next[j]) #include <bits/stdc++.h> using namespace std; #define MAX 10000000 char a[MAX], b[MAX]; int nexts[MAX]; int len_b, len_a; voi

  • 【C语言基础】字符串和格式化输入/输出2022-07-26 22:01:49

    字符串的介绍 数组由连续的存储单元组成,字符串中的字被存储在相邻的存储单元中,每个单元存储一个字符。在数组末尾位置的字符为\0,代表字符串的结束。 #define _CRT_SECURE_NO_WARNINGS #include<stdlib.h> #include<stdio.h> #include<string.h> #define PRAISE "You are an extra

  • 【C语言】二维数组scanf2022-07-24 00:31:58

      //二维数组存入输入的值 #include <stdio.h> int main() { int a[2][2]; int i, j; for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) scanf("%d", &a[i][j]); for (i = 0; i < 2; i++) { for (j = 0;

  • 1537:【例 3】校门外的树2022-07-23 15:34:33

    时间限制: 1000 ms         内存限制: 524288 KB提交数: 2738     通过数: 1233 【题目描述】 原题来自:Vijos P1448 校门外有很多树,学校决定在某个时刻在某一段种上一种树,保证任一时刻不会出现两段相同种类的树,现有两种操作: K=1K=1,读入 l,rl,r 表示在 ll 到 rr 之

  • $\text{All LCA}$2022-07-23 11:31:27

    \(1.Multiplication\) \(2.Treediv\) \(3.Euler+ST\) #include <bits/stdc++.h> using namespace std; const int N = 5e5 + 5; int n, m, S; vector <int> Link[N]; namespace solve1 { int f[N][25], dep[N]; void dfs(int u, int Fa) {

  • AcWing 237. 程序自动分析(并查集+离散化)2022-07-19 13:03:23

    题目描述 题目链接 题目思路 先进行离散化(题目中给的数据范围很大,但需要用到的很少),109 ==> 2 × 106 离散化方式: 若要求保序:排序、判重、二分 若不要求保序,用map 本题约束条件的顺序无所谓,则先考虑所有相等的约束条件(一定无矛盾),再考虑不相等的约束条件 相等则放在一个集合中,

  • 暑假集训7月19日(距离结训赛27天)2022-07-19 09:02:04

    CF补题:B题:只想到相隔偶数就算,但是没想好用什么方法计算,每一个都遍历肯定超啊原来可以和滚动优化一样,只记录上一次的位置#include <bits/stdc++.h> using namespace std; const int N=1e5+10; int a[N],pre[N],ans[N]; signed main() { int t; scanf("%d",&t); while

  • CF1705A Mark the Photographer 题解2022-07-18 14:02:53

    题意: 给定一队人的身高,将其分成两队,问能否实现前面的人均低于后面的人至少 \(x\) 个单位长度。 做法: 将这队人的身高进行排序,\(h_1\)~\(h_n\) 即为第一队,\(h_{n+1}\)~\(h_{2n}\) 即为第二队,两队前后进行比较即可。 注意: 排序的时候应为 \(1\)~\(1+n+n\) 个区域上的数值。 #include

  • 【第三章】代码清单和练习2022-07-16 00:01:02

      //代码清单3-1--是否能被5整除 int main() { int vx; printf(">>"); scanf("%d", &vx); //vx%5为真,即vx% !=0 if (vx % 5) { puts("输入的数不能被整除。"); } return 0; }   //代码清单3-2--输入的数字是否为奇数 int ma

  • CF Edu Round 131 简要题解(ABCD)2022-07-10 17:04:55

    A 分类讨论即可 . using namespace std; typedef long long ll; typedef pair<int, int> pii; int main() { int T, a11, a12, a21, a22; scanf("%d", &T); while (T--) { scanf("%d%d%d%d", &a11, &a12, &a21, &a22); if (!a

  • CF1698B Rising Sand2022-07-09 16:36:10

    cf的题目很喜欢使用分类讨论的思想。 Analysis 这B题要分两种情况讨论。 情况一:\(k=1\) 时,可累出可能最多的太高沙堆。 情况二:\(k>1\) 时,操作无效,可能的太高沙堆最大值为只可能为原值。 Proof \(k=1\) 时可以任意操作,由于题目中有最后一堆不能成为太高沙堆的限制,故答案为 \(\lfl

  • 1047 编程团体赛 很基础的题2022-07-09 14:35:24

    注意点 输入为数字掺杂字符时,用scanf会比较方便 代码 #include <iostream> #include <cstdio> using namespace std; int a[1002]; int main(){ for(int i=0;i<1002;i++){ a[i]=0; } int n; int max=-1; int maxi; int index,t,grade; scanf("%d",&n);

  • 机试练习(三)——经典算法2022-07-07 13:05:36

    排序算法 1.冒泡排序 点击查看代码 #include <cstdio> #include <algorithm> using namespace std; const int MAXN = 50; int a[MAXN]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &

  • 关于char[]数组通过scanf赋值使用上的一些问题。。2022-07-06 13:47:12

    关于char[]数组通过scanf赋值使用上的一些问题。 假如我们有这么一段代码 #include <stdio.h> int main(void){ char c1[2]; scanf("%s",c1); char c2[20]; scanf("%s",c2); printf("%s %s\n",c1,c2); return 0; } char类型数组在栈区开辟了自己的空间。当

  • 求整数n>0的阶乘和 C语言2022-07-03 16:00:44

      #include <stdio.h> int main() { int n = 0; while(scanf("%lld", &n) && n > 0) { long long sum = 0; for(int i = 1; i <= n; i++) { long long factorial = 1;

  • abc258(G)2022-07-02 22:32:06

    G - Triangle 题意:给定一个邻接矩阵,问有多少个三元组(x, y, z)满足两两顶点之间有一条边直接相连。 该题使用bitset可以快速解决。 首先预处理 bitset b[i], b[i][j] = 1表示有边,否则无边。 然后选中两个点(x, y),且(x, y)之间有边。 b[x] & b[y] 为一个新的bitset,当bitset[z] 表示

  • POJ2763 Housewife Wind (树链剖分)2022-07-01 20:37:52

    差不多是模板题,不过要注意将边权转化为点权,将边的权值赋给它所连的深度较大的点。 这样操作过后,注意查询ask()的代码有所改变(见代码注释) 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int maxn=100010; 6 int head[m

  • CF1696B NIT Destroys the Universe2022-06-27 23:31:51

    第二次打 cf Global Round。 这个第二题是真的思维,代码极短。 问题分析 本题中的 \(\text{mex}(l,r)\) 操作其实就是一个表象,瞄准最终目的 \(\forall a_i,a_i=0\) 就好办。 显然答案只有 \(3\) 种可能:\(0\),\(1\),\(2\)。下面就来证明一下这个简单明了的答案。 结论证明 \(1^{\cir

  • AcWing杯 - 第56场周赛2022-06-18 21:01:05

    比赛链接 第 56 场周赛 先放代码,题解慢慢补 A AcWing 4482. 分组 #include<bits/stdc++.h> using namespace std; const int N=105; int n; int a[N]; int main() { cin>>n; int ans=0; for(int i=1;i<=n;i++) { int x; cin>>x;

  • POJ3280 Cheapest Palindrome (区间DP)2022-06-17 20:03:45

    dp[i][j]表示将字符串子区间[i,j]转化为回文字符串的最小成本。 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #include<cmath> 5 #include<string> 6 #include<iostream> 7 using namespace std; 8 const int maxn=2010; 9 int n

  • 【线性dp】AcWing896.最长上升子序列 II2022-06-15 21:04:08

    AcWing896.最长上升子序列 II 题解 #include <iostream> #include <cstdio> using namespace std; const int N = 1010; int n, m, f[N][N]; char a[N], b[N]; int main() { scanf("%d%d",&n, &m); scanf("%s%s", a+1, b+1);

  • CF1659 Codeforces Round #782 (Div. 2) 题解2022-06-14 18:03:00

    好痛苦……我好垃圾……先把代码码一下,等到考完试再写解析吧。好久没有写题写的那么窒息了,罚时也相当爆炸。 呜呜呜呜我好垃圾……E题看了一眼不写了,后面补上(?)。 A Red Versus Blue int n, r, b; void solve(){ scanf("%d%d%d", &n, &r, &b); int mx = n / (b + 1); while (r

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有