题目链接:https://codeforces.com/contest/1384/problem/A 题意 构造 $n+1$ 个字符串,使得 $n$ 对相邻字符串的相同前缀长度对应于数组 $a$ . 题解 构造一个足够长的字符串,每次反转前缀不同处的字符即可. 代码 #include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; string s(200, 'a'); cout <&l…
http://codeforces.com/problemset/problem/182/D 题意:如果把字符串a重复m次可以得到字符串b,那么我们称字符串a为字符串b的一个因子,现在给定两个字符串S1和S2,求它们的公共因子个数. 思路: 先求最小循环节,如果最小循环节不同,那么肯定是没有公共因子的.如果相同的话,那就看循环节长度为1,2,3...是否可行. #include<iostream> #include<cstdio> #include<cstring> u…
链接: https://codeforces.com/contest/1271/problem/E 题意: At first, let's define function f(x) as follows: f(x)={x2x−1if x is evenotherwise We can see that if we choose some value v and will apply function f to it, then apply f to f(v), and so on, we'll…
题意:对于一个数\(x\),有函数\(f(x)\),如果它是偶数,则\(x/=2\),否则\(x-=1\),不断重复这个过程,直到\(x-1\),我们记\(x\)到\(1\)的这个过程为\(path(x)\),它表示这个过程中所有\(x\)的值,现在给你一个数\(n\)和\(k\),要你找出最大的数\(x\),并且\(x\)在\(path[1,n]\)中出现的次数不小于\(k\). 题解:我们对于\(x\)可以选择分奇偶来讨论. 1.假如\(x\)为奇数,那么根据题意,我们知道\(x,2x,2x…
                                                    D. Prefixes and Suffixes You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|)…
Codeforces Round #117 (Div. 2) 代码 Codeforces Round #117 (Div. 2) A. Battlefield any trench in meters numerically does not exceed b. 这个条件意味着每次都是在蓄能开始时走向下一条线段,也就是说每条线段相当于花费了\(a+b\)的时间. bfs,用\(d_i\)表示到达线段i需要经过最少的线段条数,到达\(B\)的时候直接计算欧几里得距离. B. Vasya's Cal…
今天老师(orz sansirowaltz)让我们做了很久之前的一场Codeforces Round #257 (Div. 1),这里给出A~C的题解,对应DIV2的C~E. A.Jzzhu and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has a big rectangular cho…
Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 Sec  Memory Limit: 512 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/D Description Finally it is a day when Arthur has enough money for buying an apartment. H…
Codeforces Round #422 (Div. 2) Table of Contents Codeforces Round #422 (Div. 2)Problem A. I'm bored with lifeProblem B.Crossword solvingProblem C. Hacker, pack your bags! Problem A. I'm bored with life A. I'm bored with life Holidays have finished. T…