educational codeforces string round

SMU Spring 2023 Trial Contest Round 10

A. Remove Duplicates #include <bits/stdc++.h> using namespace std; #define int long long int read() { int x = 0, f = 1, ch = getchar(); while ((ch < ' ......
Contest Spring Round Trial 2023

Codeforces 103446A - Strange Functions(凸包)

首先,根据 $\arctan$ 函数的性质,一个函数在 $x$ 处的取值是所有 $n$ 个函数中最小的,当且仅当 $|k_i\sec(x-a_i)|$ 是所有 $n$ 个函数中最小的。 和差角公式把 $\sec$ 拆开得到 $|\dfrac{k_i}{\cos(x)\cos(a_i)+\sin(x) ......
凸包 Codeforces Functions 103446A Strange

Codeforces 1804G - Flow Control(势能分析)

成功把这道小清新题做成了一道大数据结构题,我的评价是我是小丑。 首先显然要离散化对时间轴扫描线。这个除以 $2$ 下取整的操作显然启示我们往势能的方向思考,也就是我们希望能够找到某个变量,使得这个变量的均摊变化次数在可接受范围内。但是直接以每个元素的值为势能好像也不太对,因为一次全局除以 $2$ 之 ......
势能 Codeforces Control 1804G 1804

[C#]中String、String[]、List<string>相互转换及string成员substring、split简单使用

一、相互转换 1. String > String[] String s = "a,b,c,d,e"; String[] sArray = s.Split(','); 2. String[] > String string[] sArray = {"a", "b", "c", "d","e"}; s ......
String string substring 成员 split

Educational Codeforces Round 147

A 题意 思路 有前导零结果直接为0,出现在第一位的**?贡献为9**,其他地方的**?贡献为10**。 代码 #include<bits/stdc++.h> using namespace std; using ll=long long; char s[10]; int main() { int ......
Educational Codeforces Round 147

Educational Codeforces Round 147 (Rated for Div. 2)

题目链接 B 核心思路 真的需要加强了,看到这个最大值和最小值我们其实也需要往对应的最大值和最小值的相关操作去想,不如前缀最小值/前缀最大值或者是后缀最小值/后缀最大值。 这里一个比较直接的想法就是想找到不同的地方,然后看不可以扩展。那么怎么看是否可以扩展呢,如果是左边的话,就看当前的位置是不是小于 ......
Educational Codeforces Round Rated 147

Educational Codeforces Round 127 (Rated for Div. 2)

题目链接 D 核心思路 首先挖掘下操作的性质吧: x>1&&x+3<10: 1 x x+1 x+2 x+3 10 我们可以发现这样子好像对于我们的结果是没有影响的,答案还是9. 所以这个性质就挖掘出来了啊,只要我们把一段连续的插入到对应的区间里面就好了。也就是只要这个区间的左端点小于插入连续的数的最 ......
Educational Codeforces Round Rated 127

Codeforces Beta Round 96 (Div. 1) -- C. Logo Turtle (dp,记忆化搜索)

#记忆化搜索 就是暴力,多一步优化,走过的路别走了。说实话,可能是数据水了,居然能过。 const int N = 510; string s; int n, ans; bool st[501][501][2][50]; void dfs(int x, int idx, int dir, int k ......
Codeforces 记忆 Turtle Round Beta

内置函数round() 用于数字的四舍五入

内置函数: round() 用于数字的四舍五入round(5.214,2) #结果是 5.21 四舍五入规则: 要求保留位数的后一位<=4,则进位,如round(5.214,2)保留小数点后两位,结果是 5.21要求保留位数的后一位“=5”,且该位数后面没有数字,则不进位,如round(5.215, ......
函数 数字 round

Educational Codeforces Round 147 (A-D)

#A. Matching 橘子熊:这题太简单了我不想写 ##题面 Description 给定给一个带问号的字符串,求有多少种可能的数字 Input 多次询问,一次一个字符串 Output 对于每次询问,输出可能的数字的总数 数据范围与约定 2e5次询问,单词询问不超过5个字符 ##思路 主要思路 ......
Educational Codeforces Round 147 A-D

Educational Codeforces Round 39 (Rated for Div. 2) -- D. Timetable (DP)

写得很折磨人,每次dp都写个一个多小时,写出来明明觉得不难 ^.^ 题目大意:可以进行K次操作,把删除1,进行k次操作后每行第一个 1 和最后一个 1 的位置 相减的绝对值加 1 得到的结果最小。 做法:每次肯定是要从左删或者从右边删,然后顺着这个思路,先把每行的进行小于等于k次操作时, 每行最小的 ......
Educational Codeforces Timetable Round Rated

Educational Codeforces Round 147 (Rated for Div. 2) A-D题解

A. Matching 题意:给出一个数,数中可能会有?,可以用0-9替换问号,问最后有多少种方法 Solution 对于位于首位的数可以用1-9替换,对于其他位置的额、可以用0-9替换,如果首位为0则无解 void solve() { string s;cin>>s; if(s[0]=='0') ......
题解 Educational Codeforces Round Rated

SMU Spring 2023 Trial Contest Round 9

SMU Spring 2023 Trial Contest Round 9 A - Wrong Subtraction #include<bits/stdc++.h> using namespace std; typedef pair<int,int>PII; typedef pair<string ......
Contest Spring Round Trial 2023

SMU Spring 2023 Trial Contest Round 9

A. Wrong Subtraction #include <bits/stdc++.h> using namespace std; int32_t main() { int n, k; cin >> n >> k; while (k--) { if (n % 10 == 0) n /= 10; e ......
Contest Spring Round Trial 2023

【c&c++】std::string::npos的使用

std::string::nposstd::string::npos是一个常数,它等于size_type类型可以表示的最大值,用来表示一个不存在的位置,类型一般是std::container_type::size_type。 定义static const size_type npos = -1; # ......
string npos amp std

【c&c++】C++中string::npos的一些用法总结

一、关于npos的定义 在MSDN中有如下说明:basic_string::nposstatic const size_type npos = -1;//定义The constant is the largest representable value of type size_type. It i ......
string npos amp

Quasi Binary---codeforces

# Quasi Binary ## 题面翻译 **题目描述** 给出一个数n,你需要将n写成若干个数的和,其中每个数的十进制表示中仅包含0和1。 问最少需要多少个数 **输入输出格式** 输入格式: 一行 一个数 n(1≤n≤10^6) 输出格式: 最少的数的个数,并给出一种方案。 ## 题目描述 ......
codeforces Binary Quasi

Codeforces Round 866 (Div. 2)(A~C)

A. Yura's New Name 题意 在字符串$s$中添加 "" 或者 "^",使得$s$中的任意字符都必须为 "^^" 或者 "^^" 的一部分,求最少要添加的字符数量 思路 当字符串头部为 "_" 时,一定要在前面添加1个字符 "^" 当字符串尾部为 "_" 时,一定要在后面添加1个字符 ......
Codeforces Round 866 Div

js 中 对 String 的操作

// charAt():返回指定位置的字符。 const str = "hello"; const char = str.charAt(1); // "e" // charCodeAt():返回指定位置字符的Unicode编码。 const str = "hello"; const unicode ......
String js

time&datetime&string相互转换

time&datetime&string相互转换 import datetime import time # 日期时间字符串 st = "2017-11-23 16:10:10" # 当前日期时间 dt = datetime.datetime.now() # 当前时间戳 sp = time.time ......
amp datetime string time

Educational Codeforces Round 110 (Rated for Div. 2)

题目链接 C 核心思路 这个题目其实我们可以转换为把当前串转换为完美串有多少种方案呢,也就是我们从前往后一步一步往完美串去构造我们的方案。 这个思路非常巧妙,我刚开始的思路局限于算贡献去了。 完全就脱离了正确的思路。 集合定义 $f[i][0/1]表示的是处理了前i个位置,并且当前位置是0的方案数$ ......
Educational Codeforces Round Rated 110

Codeforces Round 689 (Div. 2, based on Zed Code Competition)D.Divide and Summarize

题意: 我们给定包含n个正整数的数组,我们可以对这个数组执行一些操作之后,可以让数组内元素的和成为我们想要的数。 我们对数组的执行操作一共分为三个步骤,第一个步骤是我们首先计算出数组的中间值mid。这里mid的定义不是中位数也不是均值,而是最大值和最小值的均值。也就是mid = (min + max ......

阶梯网格计数模型 & Codeforces 1770G - Koxia and Bracket 题解

更差的阅读体验(bushi) 其实 2022 年省选前联考出过类似的套路,但当时太鸽了就没有总结。 阶梯网格计数问题是指以下一类问题: 问题:给定一个 $n$ 列阶梯状网格图,第 $i$ 列高度为 $c_i$(保证 $c_i$ 不降),每次可以向上或向右走一步,不能超出网格边界(即所有经过的点 $( ......
题解 网格 阶梯 Codeforces 模型

String对象

一、 数据类型转换 数据类型 值类型(基本类型):字符串(String)、数字(Number)、布尔(Boolean [ˈbuliən])、对空(Null)、未定义(Undefined)、Symbol [ˈsɪmbəl]。 引用数据类型:对象(Object)、数组(Array)、函数(Functio ......
对象 String

string的使用方法和高级用法

字符串的定义和初始化 #include <string>using namespace std;string str1; // 定义一个空的字符串string str2 = "hello world"; // 使用字符串字面量进行初始化string str3("hello world"); // 使 ......
使用方法 方法 string

Math.ceil,Math.round,Math.floor区别

Math.ceil,Math.round,Math.floor区别 //向上取整 System.out.println("amt1=" + Math.ceil(71.01)); //四舍五入 System.out.println("amt2=" + Math.round(71.01)); //向下取 ......
Math round floor ceil

codeforces #864 div2 B

GCD Partition 这道题首先要解决一个问题,要把区间分成几块,可以证明分成两块是更优 首先我们假设把区间分成了m(>= 2)块 b1, b2, b3, ...,bm,则答案是gcd(b1, b2, b3,..., bm),则b1,b2是 gcd(b1, b2, b3,..., bm)的倍数 ......
codeforces div2 864 div

string.h 库常用函数

下面是常见的string.h函数的使用方法及参数说明: 1. strlen 函数原型:size_t strlen(const char *s); 函数说明:计算字符串s的长度,不包括末尾的'\0'。 参数说明:s为要计算长度的字符串。 返回值:返回字符串s的长度。 2. strcpy 函数原型:ch ......
函数 常用 string

string

string string toupper(),将string字符串中的字符转为大写字符 string s="SADfdfsf"; s[i]=toupper(s[i]); tolower(),将string字符串中的字符转为小写字符 string s="SADfdfsf"; s[i]=toupper ......
string

Educational Codeforces Round 147 (Rated for Div. 2) A ~ C

A. Matching 题意:   给定一个字符串,将其中的 ‘?’ 替换成数字,不含前导0,如果字符串前导为0,输出0.。 分析:   每个地方有10种可能方案,在特判一下第一位就行了。 ......
Educational Codeforces Round Rated 147