【 Codeforces Round #519 by Botan Investments B】Lost Array
【链接】 我是链接,点我呀:)
【题意】
【题解】
枚举k
不难根据a得到x[0..k-1]
然后再根据a[k+1..n]来验证一下得到的x是否正确就好。
【代码】
#include <bits/stdc++.h>
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
using namespace std;
const int N = 1000;
int n;
int a[N+10];
int x[N+10];
vector<int> v;
int main()
{
ios::sync_with_stdio(0),cin.tie(0);
cin >> n;
rep1(i,1,n) cin >> a[i];
a[0] = 0;
rep1(k,1,n){
/*
x0 x1 x2 x[k-1]
a0 a1 a2 a3.. a[k]
*/
for (int i = 0;i < k;i++){
//a[i+1]=x[i]+a[i]
x[i] = a[i+1]-a[i];
}
int ok = 1;
for (int i = k+1;i <= n;i++)
if (a[i]!=x[(i-1)%k]+a[i-1]){
ok = 0;
}
if (ok) v.push_back(k);
}
cout<<(int)v.size()<<endl;
for (int i = 0;i < (int)v.size();i++){
cout<<v[i]<<' ';
}
return 0;
}
【 Codeforces Round #519 by Botan Investments B】Lost Array的更多相关文章
- 【Codeforces Round #519 by Botan Investments E】Train Hard, Win Easy
[链接] 我是链接,点我呀:) [题意] [题解] 设每个人做第一题.第二题的分数分别为x,y 我们先假设没有仇视关系. 即每两个人都能进行一次训练. 那么 对于第i个人. 考虑第j个人对它的贡献 如 ...
- 【Codeforces Round #519 by Botan Investments A】 Elections
[链接] 我是链接,点我呀:) [题意] [题解] 枚举k 那么另外一个人的得票就是nk-sum(ai) 找到最小的满足nk-sum(ai)>sum(ai)的k就ok了 [代码] #includ ...
- 【Codeforces Round #519 by Botan Investments C】 Smallest Word
[链接] 我是链接,点我呀:) [题意] [题解] 模拟了一两下.. 然后发现. 对于每一个前缀. 组成的新的最小字典序的字符串 要么是s[i]+reverse(前i-1个字符经过操作形成的最大字典序 ...
- 【Codeforces Round #519 by Botan Investments D】Mysterious Crime
[链接] 我是链接,点我呀:) [题意] 相当于问你这m个数组的任意长度公共子串的个数 [题解] 枚举第1个数组以i为起点的子串. 假设i..j是以i开头的子串能匹配的最长的长度. (这个j可以给2. ...
- Codeforces Round #519 by Botan Investments
Codeforces Round #519 by Botan Investments #include<bits/stdc++.h> #include<iostream> #i ...
- Codeforces Round #519 by Botan Investments(前五题题解)
开个新号打打codeforces(以前那号玩废了),结果就遇到了这么难一套.touristD题用了map,被卡掉了(其实是对cf的评测机过分自信),G题没过, 700多行代码,码力惊人.关键是这次to ...
- Codeforces Round #519 by Botan Investments F. Make It One
https://codeforces.com/contest/1043/problem/F 题意 给你n个数,求一个最小集合,这个集合里面数的最大公因数等于1 1<=n<=3e5 1< ...
- Codeforces Round #519 by Botan Investments翻车记
A:枚举答案即可.注意答案最大可达201,因为这个wa了一发瞬间爆炸. #include<iostream> #include<cstdio> #include<cmat ...
- 【Codeforces Round #519】
A:https://www.cnblogs.com/myx12345/p/9872082.html B:https://www.cnblogs.com/myx12345/p/9872124.html ...
随机推荐
- poj2594——最小路径覆盖
Description Have you ever read any book about treasure exploration? Have you ever see any film about ...
- selenium3 + python - cookie定位
from selenium import webdriverfrom selenium.webdriver.support.wait import WebDriverWaitimport time d ...
- 明解C语言
本文为阅读书籍<明解C语言-中级篇>所积累的知识点及编译书本代码时遇到的问题.部分对应代码在\Code_2018\BK_明解C语言目录下.每个代码内都含有程序功能.思路.疑惑点等内容,如有 ...
- POJ 1946 DP
折腾了一晚上 明天再写.. 2016.5.17 23:59 -> -> #include <cstdio> #include <cstring> #include ...
- POJ 1523 Tarjan求割点
SPF Description Consider the two networks shown below. Assuming that data moves around these network ...
- 如何在linux下搭建svn服务
• 安装svn 使用命令 yum install subversion 如果提示上述错误,请以管理员身份运行 使用命令su root 再执行 yum install subversion 2,查看sv ...
- B - Alyona and mex(构造)
Problem description Alyona's mother wants to present an array of n non-negative integers to Alyona. ...
- mybatis 传map参数
第一步在你的mapper写上: List<WeixinUserLocationList> findweixinUserLocations(@Param("params" ...
- # --with-http_sub_module模块
作用: http内容替换 语法 第一种语法: sub_filter string:要替换的内容 替换后的内容 这个模块只能替换第一个匹配的字符串,如果需要匹配全部替换,则用到下面的第三种语法配置 第二 ...
- 自学Python八 爬虫大坑之网页乱码
Bug有时候破坏的你的兴致,阻挠了保持到现在的渴望.可是,自己又非常明白,它是一种激励,是注定要被你踩在脚下的垫脚石! python2.7中最头疼的可能莫过于编码问题了,尤其还是在window环境下, ...