atcoder another contest string

AtCoder ABC 299 ABCDEFG

A - Treasure Chest 题意 给定由 $\texttt{.}$、$\texttt{|}$、$\texttt{}$ 三种字符组成的长度为 $n$ 的字符串 $s$,保证 $\texttt{|}$ 的个数为 $2$,$\texttt{}$ 的个数为 $1$。 判断 $\texttt{*}$ ......
AtCoder ABCDEFG ABC 299

AtCoder Regular Contest 111 F Do you like query problems?

洛谷传送门 AtCoder 传送门 挺有意思的计数。 计数感觉很难做,不妨转成期望,期望又可以转成概率之和。 考虑枚举 $w \in [0,m-1]$,把 $> w$ 的数设为 $1$,$\le w$ 的数设为 $0$。那么期望就是所有 $w$,$a_i$ 为 $1$ 的概率之和。对于一个 $i$, ......
problems AtCoder Regular Contest query

Atcoder题解:Agc056_e

$$也想养老鼠捏$$ 先把当前要解决的点旋转到位置 $n$,问题不变。求 $n$ 次即可。 我们先来看两个没有结果的解法。 一就是一 我们先考虑暴力 $dp$,设 $dp_{i,mask}$ 表示当前已经安放了 $i$ 个奶酪,被喂饱的老鼠的集合为 $mask$ 的概率。容易发现 $i$ 其实就是 ......
题解 Atcoder Agc 056

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

Atcoder Beginner Contest 299 G

对于要打印的 $B$,我们首先尝试确定 $B_1$。 让 $f(x) (1≤x≤M)$ 是最大的 $i$,使 $A_i = x$。 对于 $r:=\underset{{{1≤x≤M}}}{\min}f(x)$,我们可以证明 $B_1$ 是 $A_1 ,A_2 ,...,A_r$ 中的一个(否则,$B ......
Beginner Atcoder Contest 299

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

AtCoder Beginner Contest 299

A - Treasure Chest (abc299 a) 题目大意 给定一个包含 |*.的字符串,其中|两个,*一个,问*是否在两个|之间。 解题思路 找到两个|的下标$l, r$以及 *的下标$mid$,看看是否满足 $l < mid < r$即可。 神奇的代码 ```cpp #include ......
Beginner AtCoder Contest 299

AtCoder Beginner Contest 283 Ex Popcount Sum

洛谷传送门 AtCoder 传送门 记录一下这个神奇的套路。 首先有 $\operatorname{popcount}(n) = n - \sum\limits_{i=1}^{\infty} \left\lfloor\frac{n}{2^i}\right\rfloor$。证一下: $$\operat ......
Beginner Popcount AtCoder Contest 283

String对象

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

AtCoder Regular Contest 115 D Odd Degree

洛谷传送门 AtCoder 传送门 若连通块是一棵树,考虑钦定 $k$ 个点为奇度点,方案数为 $\binom{n}{k}$。对于叶子,如果它是奇度点,那么连向它父亲的边要保留,否则不保留。这样自底向上考虑,任意一条边的保留情况都可以唯一确定,所以最后方案数就是 $\binom{n}{k}$。 若连 ......
AtCoder Regular Contest Degree 115

string的使用方法和高级用法

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

AtCoder Regular Contest 114 F Permutation Division

洛谷传送门 AtCoder 传送门 这题居然是之前某场模拟赛(contest 701)的 T1……(@Vidoliga 场切但是被卡常/bx) 下面记 $m$ 为原题面中的 $K$,$a_i$ 为原题面中的 $P_i$。 不难发现后手的策略是把所有段按照段的第一个数从大到小排序接在一起。 考虑若 $ ......
Permutation Division AtCoder Regular Contest

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

AtCoder Regular Contest 114 D Moving Pieces on Line

洛谷传送门 AtCoder 传送门 挺有意思的题。 首先显然地,一个棋子不会走回头路。于是一个棋子沿着边走的效果就是区间异或。 更进一步,设 $s_i$ 为 $i-1 \to i$ 的边颜色与 $i \to i+1$ 的边颜色是否相同(差分),相当于对于每个 $i$ 都选择 $s_{a_i}$ 和 ......
AtCoder Regular Contest Moving Pieces

string类,stringbuilder以及stringBuffer

String类 string对象用于保存字符串,也就是一组字符序列 “jack”字符串常量,双引号括起来的字符序列 字符串的字符使用Unicode编码,一个字符占两个字节 String类有多构造器,构造器的重载 string实现了两个接口:Serizlizable:String可串行化:可以在网络上 ......
stringbuilder stringBuffer string

[Educational Codeforces Round 147 (Rated for Div. 2)](https://codeforc.es/contest/1821)题解A~D

A: 思路: 首字母如果是0,直接输出0。 如果首字母是?,提供九种方案,之后每一个?提供10种方案。 void solve(){ string s; cin>>s; if(s[0]=='0'){ cout<<"0"<<endl; return ; } int ans=1; for(int i=0; ......

Invalid prop: type check failed for prop "defaultExpandAll". Expected Boolean, got String with value "true".

vue中使用element-ui 报错如下,defaultExpandAll 关键词页面也搜不到 [Vue warn]: Invalid prop: type check failed for prop "defaultExpandAll". Expected Boolean, got String ......
quot prop defaultExpandAll Expected Invalid

C++——string 成员函数 length(),size() 和 C strlen() 的区别

// 方法一:调用 length() 或 size() string strTest = "test"; strTest.length(); // 4 strTest.size(); // 4 // 方法二:转为 C 风格字符串,调用 strlen() strlen(strTest.c_str()) ......
函数 成员 string length strlen

Mysql - Order By 踩坑记录(【string类型】)

记录:在用order by排序时,发现结果与“逻辑” 不符合!!! 猜想:以为是ASCII的原因? 验证:数字0到9的ASCII码值分别为48到57,所以排除此原因。 最后通过查资料 order by int ,突然发现是数据类型的问题! 总结: 1、当order by 排序字段 为数字时,则符合按 ......
类型 string Mysql Order By

java判断string变量是否是数字的六种方法

原文地址 zhuanlan.zhihu.com java判断string变量是否是数字的六种方法 残枫cps ​目录收起 1.用正则表达式2.用JAVA自带的函数3.使用org.apache.commons.lang: 空格 "" 的时候也会当成一个数字4、判断ASCII码值5、逐个判断str中的字 ......
变量 数字 方法 string java

string头文件的详细使用

一、初始化初始化有两种方式,其中使用等号的是拷贝初始化,使用括号的是直接初始化。 1.字符串直接初始化 string str1="hello world"; string str2("hello world") 2.复制初始化 string str3=str1;//str3="hello world ......
文件 string

std::string对象被释放后仍然访问std::string::c_str()返回的指针(访问已经释放掉的内存)的一些总结

一个值得注意的事情 今天在调试程序,发现一个严重又很难排查的问题! 有关如何正确使用函数的”返回值“。 先看一下简单代码: #include <iostream> using namespace std; const char *test1() { std::string str = "hello" ......
string 指针 std 对象 内存

模拟赛 & VP & Contest 记录

CatOJ C140(初中) $100+93+100+10=303$,Rank 1。 是个 dp 场,A 题期望 dp,B 题神奇猜结论,C 题换根 dp,D 题树上博弈 dp。 A 题设 $f_u$ 为填满子树 $u$ 的期望次数,$s_u$ 为 $u$ 子树大小,容易得到 $f_u=f_v+\f ......
模拟赛 amp Contest VP

字符串string和STL总结

设string s 查找函数 1.a=s.find("me",a); 以下标a开头查找字符串me 找到了就返回下标到a找不到a就是-1 2.a=s.find(0,2,‘3’); 在0到1内查找字符3 找到了就返回下标到a找不到a就是-1 比较函数compare s.compare(s.length( ......
字符串 字符 string STL

Atcoder Beginner Contest 298---E

题目:E - Unfair Sugoroku (atcoder.jp) 分析:这题状态转移方程挺好推的,但是用dp解是我没想到的 dp[i][j][0]表示T在i点,A在j点且轮到T走时赢的概率 dp[i][j][1]表示T在i点,A在j点且轮到A走时赢的概率 代码: #include <bits/ ......
Beginner Atcoder Contest 298