题目链接:http://codeforces.com/problemset/problem/113/B 题目大意: 多组数据每组给定3个字符串T,Sbeg,Sed,求字符串T中有多少子串是以Sbeg开头,Sed结尾的 分析: 难点在哈希函数的编写,如果直接存string会爆内存,不能用STL自带哈希函数,用了会Wa. 代码如下: #include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i &l…
题目链接 B. Petr# time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Long ago, when Petya was a schoolboy, he was very much interested in the Petr# language grammar. During one lesson Petya got i…
题目连接: Petr and Permutations 题意:给出一个1到n的序列,Petr打乱了3n次,Um_nik打乱了7n+1次,现在给出被打乱后的序列,求是谁打乱的. 题解:因为给出了一个3*n和一个7*n+1,发现这两个当一个为奇数另一个一定为偶数,所以可以联想和奇偶性质有关.但是这里面要算最短几步能把当前的序列变成1-n.这里我算错~~顺便学了一下如何将置换序列复原. #include<bits/stdc++.h> using namespace std; typedef pair…
Description\text{Description}Description Given an array a[], swap random 2 number of them for 3n or (7n+1) times.\text{Given an array }a[],\text{ swap random 2 number of them for }3n\text{ or }(7n+1)\text{ times.}Given an array a[], swap random 2 num…
The Meeting Place Cannot Be Changed CodeForces - 982F Petr is a detective in Braginsk. Somebody stole a huge amount of money from a bank and Petr is to catch him. Somebody told Petr that some luxurious car moves along the roads without stopping. Petr…