1.题目大意 求一个长度不超过80的字符串的最小周期. 2.思路 非常简单,基本就是根据周期的定义做出来的,几乎不需要过脑. 3.应该注意的地方 (1) 最后输出的方式要注意,不然很容易就PE了.不过个人认为,其实这题Sample Output给的不好 (2) 注意输出的要求是最小周期 4.代码 #include"stdio.h" #include"string.h" #define maxn 80 int main() { int T,m,i,j,flag; ch…
UVa OJ 455 Periodic Strings A character string is said to have period k if it can be formed by concatenating one or more repetitions of another string of length k. For example, the string "abcabcabcabc" has period 3, since it is formed by 4 repe…
Periodic Strings 模板 题意分析 判断字符串的最小周期 代码总览 /* Title:UVA.455 Author:pengwill Date:2016-12-16 */ #include <iostream> #include <cstdio> #include <cstring> using namespace std; char str[100]; int main() { int n; scanf("%d",&n); w…
题意:给出一个字符串,找出它的最小的周期,枚举从1到len的周期,看是否满足. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ]; int main() { int ncase,t,i,k,j,len; scanf("%d",&ncase); while(ncase--) { scanf(…
 Periodic Strings  A character string is said to have period k if it can be formed by concatenating one or more repetitions of another string of length k. For example, the string "abcabcabcabc" has period 3, since it is formed by 4 repetitions o…
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=20&page=show_problem&problem=1822 题目意思:有一条 L 厘米长的杆,上面有 n 只蚂蚁,给出每只蚂蚁的朝向以及离杆上最左端的距离,问 T 秒之后每只蚂蚁到达的位置,如果 T 秒后某个位置有多只蚂蚁同时到达,那么这堆蚂蚁处于的位置 + Turning,如果超过这条杆的长度,输出F…
题意:给三种操作 1.在p位置插入一个字符串. 2.从p位置开始删除长度为c的字符串 3.输出第v个历史版本中从p位置开始的长度为c的字符串 解法:可以用平衡树做,但是不会.后来又听说可一用一个叫rope的神奇的STL,学习了一下,用法基本和string一样.roap的内部是用平衡树实现的,历史版本和当前版本可以共享一些内存,插入和删除整段字符串效率很高.是可持久化的数据结构. //Time: 952 MS #include <iostream> #include <ext/rope&g…
Tango Tango Insurrection Time Limit: 3000MS     64bit IO Format: %lld & %llu Submit Status uDebug You are attempting to learn to play a simple arcade dancing game. Thegame has 4 arrows set into a pad: Up, Left, Down, Right. While a songplays, you wat…
数论题,考查了本原勾股数(PPT) 对一个三元组(a,b,c)两两互质 且满足 a2 + b2 = c2 首先有结论 a 和 b 奇偶性不同 c总是奇数(可用反证法证明,不赘述) 设 a为奇数 b为偶数 a,b,c互质 有 a2 = c2 – b2 =(c-b)(c+b) 由于c和b互质 且a为奇数 (c-b)与(c+b)也互质 令(c+b)=s2  (c-b)=t2 有 c=(s2+t2)/2 b=(s2-t2)/2 a=st 这时可以枚举s 和 t 保证 s t 互质 非本原勾股数只需乘上一…
最近在准备找工作的算法题,刷刷LeetCode,以下是我的解题报告索引,每一题几乎都有详细的说明,供各位码农参考.根据我自己做的进度持续更新中......                              本文地址 LeetCode:Reverse Words in a String LeetCode:Evaluate Reverse Polish Notation LeetCode:Max Points on a Line LeetCode:Sort List LeetCode:Ins…