题目地址

题目链接

题解

不会算复杂度真是致命,暴力枚举k每次计算是n/2+n/3+n/4+...+1的,用调和级数算是\(O(nlogn)\)的...

如果写哈希表的话能够\(O(nlogn)\),或者直接拿个set存就\(O(nlognlogn)\)。

进制要选好,233不能过,2333过的点会多一点,然后选13131才过了

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
typedef unsigned long long ull;
const int N = 200010;
const ull base = 13131;
using namespace std; int Ans, n, a[N], ans[N], cnt = 0;
ull h1[N], h2[N], p[N];
set<ull> st; ull cal1(int l, int r) { return h1[r] - h1[l - 1] * p[r - l + 1]; } ull cal2(int l, int r) { return h2[l] - h2[r + 1] * p[r - l + 1]; } int ins(int x) {
st.clear();
for(int l = 1; l + x - 1 <= n; l += x) {
int r = l + x - 1;
ull ha = min(cal1(l, r), cal2(l, r));
st.insert(ha);
}
return (int)st.size();
} int main() {
scanf("%d", &n); p[0] = 1;
for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
for(int i = 1; i <= n; ++i) h1[i] = h1[i - 1] * base + a[i], p[i] = p[i - 1] * base;
for(int i = n; i; i--) h2[i] = h2[i + 1] * base + a[i];
for(int i = 1; i <= n; ++i) {
int num = ins(i);
if(num > Ans) { Ans = num; cnt = 0; }
if(num == Ans) ans[++cnt] = i;
}
printf("%d %d\n", Ans, cnt);
for(int i = 1; i <= cnt; ++i) printf("%d ", ans[i]);
return 0;
}

LOJ#2427. 「POI2010」珍珠项链 Beads的更多相关文章

  1. LOJ#2452. 「POI2010」反对称 Antisymmetry

    题目描述 对于一个 \(0/1\) 字符串,如果将这个字符串 \(0\) 和 \(1\) 取反后,再将整个串反过来和原串一样,就称作「反对称」字符串.比如 \(00001111\) 和 \(01010 ...

  2. Loj #2192. 「SHOI2014」概率充电器

    Loj #2192. 「SHOI2014」概率充电器 题目描述 著名的电子产品品牌 SHOI 刚刚发布了引领世界潮流的下一代电子产品--概率充电器: 「采用全新纳米级加工技术,实现元件与导线能否通电完 ...

  3. Loj #3096. 「SNOI2019」数论

    Loj #3096. 「SNOI2019」数论 题目描述 给出正整数 \(P, Q, T\),大小为 \(n\) 的整数集 \(A\) 和大小为 \(m\) 的整数集 \(B\),请你求出: \[ \ ...

  4. Loj #3093. 「BJOI2019」光线

    Loj #3093. 「BJOI2019」光线 题目描述 当一束光打到一层玻璃上时,有一定比例的光会穿过这层玻璃,一定比例的光会被反射回去,剩下的光被玻璃吸收. 设对于任意 \(x\),有 \(x\t ...

  5. Loj #3089. 「BJOI2019」奥术神杖

    Loj #3089. 「BJOI2019」奥术神杖 题目描述 Bezorath 大陆抵抗地灾军团入侵的战争进入了僵持的阶段,世世代代生活在 Bezorath 这片大陆的精灵们开始寻找远古时代诸神遗留的 ...

  6. Loj #2542. 「PKUWC2018」随机游走

    Loj #2542. 「PKUWC2018」随机游走 题目描述 给定一棵 \(n\) 个结点的树,你从点 \(x\) 出发,每次等概率随机选择一条与所在点相邻的边走过去. 有 \(Q\) 次询问,每次 ...

  7. Loj #3059. 「HNOI2019」序列

    Loj #3059. 「HNOI2019」序列 给定一个长度为 \(n\) 的序列 \(A_1, \ldots , A_n\),以及 \(m\) 个操作,每个操作将一个 \(A_i\) 修改为 \(k ...

  8. Loj #3056. 「HNOI2019」多边形

    Loj #3056. 「HNOI2019」多边形 小 R 与小 W 在玩游戏. 他们有一个边数为 \(n\) 的凸多边形,其顶点沿逆时针方向标号依次为 \(1,2,3, \ldots , n\).最开 ...

  9. Loj #3055. 「HNOI2019」JOJO

    Loj #3055. 「HNOI2019」JOJO JOJO 的奇幻冒险是一部非常火的漫画.漫画中的男主角经常喜欢连续喊很多的「欧拉」或者「木大」. 为了防止字太多挡住漫画内容,现在打算在新的漫画中用 ...

随机推荐

  1. 在lnmp1.3布置的web服务器上运行thinkphp3.2.3项目pathinfo路径模式

    通过我的经历希望能给大家带来一些帮助: 我是在Linux系统上通过https://lnmp.org/install.html设置Nginx服务器,使用的是lnmp1.3版本,之后将一个thinkphp ...

  2. Rpgmakermv(14)Archeia_Steamworks

    作用: 接入steam成就 -----------------------------------------------------------------------------------原文: ...

  3. asp.net GridView增加删除功能

    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)    {        string id ...

  4. La Vie en rose (模拟)

    #include<bits/stdc++.h> using namespace std; ; ; int T, n, m; char str1[maxm], str2[maxn]; int ...

  5. 开源IOT平台

    用于IoT应用程序开发的10大开源软件: 1. DeviceHive DeviceHive基于AllJoyn的Data Art设备,同时也是AllSeen的联盟成员.这一款免费开源机器和机器通信(M2 ...

  6. 【转】Apache Kylin 2.0为大数据带来交互式的BI

    本文转载自:[技术帖]Apache Kylin 2.0为大数据带来交互式的BI 编者注:Kyligence的联合创始人兼CEO Luke Han在上做题为“”的演讲. 基于Hadoop的SQL一直在被 ...

  7. ElasticSearch相关文章推荐

    1. ElasticSearch查询:http://www.cnblogs.com/ljhdo/p/4486978.html 2. Elasticsearch Java API 的使用—多条件查询:h ...

  8. C#获取驱动器盘符

    一.使用ManagementObjectSearcher类 static void Main(string[] args) { SelectQuery selectQuery = new Select ...

  9. bzoj2656 [Zjoi2012]数列(sequence)

    题目链接 好久没写高精度了,调了很久QAQ 如果直接递归计算答案的话肯定会T 发现一个数不管是分成一奇一偶还是直接>>1,都会重复计算很多东西 我们只需要在递归的时候实时维护一个xx(an ...

  10. 获取select被选中的option的值

    <select id="select">      <option>绥江</option>      <option>西江</ ...