多行字符串使用fstring需要注意每行都要加fstring 如果使用三个双引号
转载
2019-08-08 12:04:00
94阅读
2评论
'f-strings’是Python的一种新的字符串格式化方法,要使用f-strings,只需在字符串前加上f,语法格式如下:f ' <text> { <exp
原创
2023-02-06 16:23:37
119阅读
https://blog.csdn.net/qq_29027865/article/details/84850683
原创
2021-05-25 11:12:54
23阅读
学过 Python 的朋友应该都知道 f-strings 是用来非常方便的格式化输出的,觉得它的使用方法无外乎就是 print(f'value = { value }',其实,f-stri...
原创
2021-10-22 17:58:18
466阅读
1、建议小写f: name = "宝元"age = 18sex = "男"msg = F"姓名:{name},性别:{age},年龄:{sex}"msg1 = f"姓名:{name},性别:{age},年龄:{sex}"print(msg)print(msg1)结果: 姓名:宝元,性别:18,年龄:
原创
2022-12-23 00:59:14
93阅读
目 录一、字符串格式化方法概览二、format() 常用格式化 1、通过位置 2、通过关键字参数 3、通过对象属性 4、通过下标 5、格式限定符 ...
转载
2022-06-02 20:46:06
151阅读
字符串插值是一种将变量嵌入字符串的方法。它使操作和丰富字符串变得容易。因
原创
2022-01-20 09:47:31
134阅读
f-Strings语法与str.format()使用的语法类似,但较少细节啰嗦,只需要在格式化字符串前加f或F即可。看看这是多么容易可读:name = "tom"
age = 2
print(f"猫的名字叫{name},今年{age}岁了")输出:猫的名字叫tom,今年2岁了格式化时可以使用函数:name = "tom"
age = 2
print(F"猫的名字叫{name.up
原创
2023-11-02 11:41:47
100阅读
Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiation by a non-...
原创
2022-03-14 10:24:53
432阅读
Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiation by a non-...
原创
2021-09-06 14:52:05
776阅读
题目描述 You are given a string s s s of length n n n consisting of lowercase English letters. For two given strings s s s and t t t , say S S S is the se
原创
2021-09-26 09:39:36
10000+阅读
CF985F Isomorphic Strings 我们只需要把每个字符对应成 \(01\) 串就行了, \(0\) 代表当前位置不是这个字符, \(1\) 代表是, 然后求一遍 \(Hash\) , 每次 \(get\) 然后 \(sort\) , 判断两段是否相等即可. \(code:\) #i ...
转载
2021-09-03 15:46:00
63阅读
2评论
贪心,求出前$i$个字符串所能组成的字典序最小的字符串$ans$(特别的,这里的字典序有$ab>abc$),同时保证剩下的长度能通过$l_{i+1},...,l_{n}$拼接 考虑插入一个字符串$s_{i+1}$,在$ans$的任意拼接处(包括开头)可以替换上这个串,之后使得$ans$的字典序最小且
转载
2020-10-11 20:28:00
54阅读
2评论
题意:给n个串ti,ps,i是s在ti中出现的次数,要求找到s,使得$\sum_
转载
2019-04-19 11:28:00
37阅读
F. Strings and Queries time limit per test 2.5 s memory limit per test 256 MB input standard input output standard output You are given a set of n str
转载
2019-03-13 21:47:00
32阅读
2评论
题意:给定两个长度均为n且由小写字母组成的字符串,可以进行若干次操作,每次从两个串中分别选一个长度相等的子串进行翻转,问是否存在能使两串相等的一系列操作方案 n<=2e5 思路:首先如果每种字母的个数不相同显然NO 如果有某种字母出现超过两次显然YES,只要将两个字母移动到一起之后反复选择他便能无限
转载
2019-11-05 15:57:00
41阅读
2评论
题意: 给出两个长度相同的字符串,询问能否通过每次翻转两个串相同长度的区间使得两个串一样。 题解: /* *CF1256F *题意: *给定两个长度一样的仅有小写字母的字符串 *每次可以从两个串中分别选一个长度相等的子串进行翻转 *询问是否存在使两个串相等的操作方案 *题解: *首先每种字母的个数不
转载
2020-09-08 19:40:00
35阅读
2评论
LINK建出广义SAMSAMSAM后,只需要知道经过每个节点的权值和是多少即可也就是对每个节点求出∑ci∗ps,i\sum\limits c_i*p_{s,i}∑ci∗ps,i我们很容易知道一个节点内的字符串共出现过sizusiz_usizu次,sizu=∑pu,isiz_u=\sum p_{u,i}sizu=∑pu,i不过权值cic_ici似乎不同啊…没关系,那就每次插入前缀时,令那个节点的权值加上cic_ici那么这个节点的所有父亲都会有这个收益,最后来一遍树形dpdpdp即可
原创
2021-08-27 09:47:47
81阅读
LINK建出广义SAMSAMSAM后,只需要知道经过每个节点的权值和是多少即可也就是对每个节点求出∑ci∗ps,i\sum\limits c_i*p_{s,i}∑ci∗ps,i我们很容易知道一个节点内的字符串共出现过sizusiz_usizu次,sizu=∑pu,isiz_u=\sum p_{u,i}sizu=∑pu,i不过权值cic_ici似乎不同啊…没关系,那就每次插入前缀时,令那个节点的权值加上cic_ici那么这个节点的所有父亲都会有这个收益,最后来一遍树形dpdpdp即可
原创
2022-02-06 14:19:16
11阅读
You are given n strings ti. Each string has cost ci. Let's define the function of string , where ps, i is the number of occurrences of s in ti, |s| is
转载
2019-02-24 19:41:00
54阅读
2评论