杭电ACM比赛的一道题目,A.Shooshuns and SequenceTime Limit :4000/2000ms (Java/Other) Memory Limit :524288/262144K (Java/Other)Total Submission(s) :130 Accepted Submission(s) :34Problem DescriptionOne day shooshuns found a sequence of n integer

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/07 16:53:29

杭电ACM比赛的一道题目,A.Shooshuns and SequenceTime Limit :4000/2000ms (Java/Other) Memory Limit :524288/262144K (Java/Other)Total Submission(s) :130 Accepted Submission(s) :34Problem DescriptionOne day shooshuns found a sequence of n integer
杭电ACM比赛的一道题目,
A.Shooshuns and Sequence
Time Limit :4000/2000ms (Java/Other) Memory Limit :524288/262144K (Java/Other)
Total Submission(s) :130 Accepted Submission(s) :34
Problem Description
One day shooshuns found a sequence of n integers,written on a blackboard.The shooshuns can perform one operation with it,the operation consists of two steps:
1 Find the number that goes k-th in the current sequence and add the same number to the end of the sequence;
2 Delete the first number of the current sequence.
The shooshuns wonder after how many operations all numbers on the board will be the same and whether all numbers will ever be the same.
Input
The first line contains two space-separated integers n and k (1≤k≤n≤105).
The second line contains n space-separated integers:a1,a2,...,an (1≤ai≤105) the sequence that the shooshuns found.
Output
Print the minimum number of operations,required for all numbers on the blackboard to become the same.If it is impossible to achieve,print -1.
Sample Input
3 2
3 1 1
3 1
3 1 1
Sample Output
1
-1
Source
Codeforces
我想知道怎么去确定一个最大的操作次数,若大于这个次数就判断为一直不相等,然后输出-1?

杭电ACM比赛的一道题目,A.Shooshuns and SequenceTime Limit :4000/2000ms (Java/Other) Memory Limit :524288/262144K (Java/Other)Total Submission(s) :130 Accepted Submission(s) :34Problem DescriptionOne day shooshuns found a sequence of n integer
经过刚才的讨论,大家都学习到了.希望你在ACM的道路上取得长足进步.

杭电ACM比赛的一道题目,A.Shooshuns and SequenceTime Limit :4000/2000ms (Java/Other) Memory Limit :524288/262144K (Java/Other)Total Submission(s) :130 Accepted Submission(s) :34Problem DescriptionOne day shooshuns found a sequence of n integer 杭电ACM比赛的题目B.Little Elephant and NumbersTime Limit :4000/2000ms (Java/Other) Memory Limit :524288/262144K (Java/Other)Total Submission(s) :33 Accepted Submission(s) :12Problem DescriptionThe Little Elephant loves numbers.He has a positiv 哪里有ACM比赛的答案,哪个平台的题目都可以 杭电acm第3809题的详细思路 杭电ACM 3809的详细解题思路是什么 杭电acm怎么查看自己ac过的代码 杭电acmd 字打错了,是 杭电acm的超时是什么意思 acm 1008 杭电 什么意思请帮我解释一下,谢谢!题目地址 http://acm.hdu.edu.cn/showproblem.php?pid=1008 杭电acm 什么思路啊 ACM题目:请问杭电1358的题目意思是什么?以下是题目:DescriptionFor each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126,inclusive),we want to know whether the prefix is a periodic s 入门ACM题目,Problem Description无论是杭电的HDOJ,还是浙大的ZOJ,A+B问题都摆着第一个位置,不过大家都做过A+B,一模一样的题目显然太看不起大家了,所以我们改下规则,描述如下:我们定义26个字母(A 杭电acm 2034wrong answer Problem Description参加过上个月月赛的同学一定还记得其中的一个最简单的题目,就是{A}+{B},那个题目求的是两个集合的并集,今天我们这个A-B求的是两个集合的差,就是做集合 acm的一道c语言问题 有关ACM一道题,你的任务是计算a+b.这是为了acm初学者专门设计的题目.你肯定发现还有其他题目跟这道题的标题类似,这些问题也都是专门为初学者提供的.输入格式输入包含一系列的a和b对,通 杭电acm 1008 题我的为什么是wrong answer 杭电acm 2035 题的算法是怎样的,杭电acm 2035 题的算法是怎样的,我要算法分析,不要代码!Problem Description求A^B的最后三位数表示的整数.说明:A^B的含义是“A的B次方”Input输入数据包含多个测试实 杭电acm的一道题,不知道自己错在哪,求助Input输入数据包含多个测试实例,每个测试实例占一行,每行的开始是一个整数n(3 求助一道ACM题一道很简单的ACM题目,题在这里我写的代码如下:#include using namespace std;int main(){int n,m[30];cin>>n;for(int i=0;i=0;j--){cout