Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #define pii pair <int,int>
- #define pb(x) push_back(x)
- using namespace std;
- using ll = long long;
- using ld = long double;
- using db = double;
- void cv(vector <int> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvl(vector <ll> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvv(vector <vector <int> > &v){
- for (auto x: v) cv(x);
- cout<<"\n";
- }
- void cvb(vector <bool> v){
- for (bool x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvs(vector <string> v){
- for (auto a: v){
- cout<<a<<"\n";
- }
- }
- void cvp(vector <pii> a){
- for (auto p: a){
- cout<<p.first<<' '<<p.second<<"\n";
- }
- cout<<"\n";
- }
- ll p = 101, mod=2e9+7;
- /*
- 6 2
- 1 1 2 2 1 1
- */
- bool sh=0;
- int main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- //int n = s.size();
- int n, m; cin>>n>>m;
- vector <int> s(n);
- for (int i = 0; i < n; ++i){
- cin>>s[i];
- }
- vector <int> ans = {n};
- vector <ll> powp(n,1), pf(n), repf(n);
- for (int i = 1; i < n; ++i){
- powp[i] = powp[i - 1] * p % mod;
- }
- pf[0] = s[0];
- repf[n - 1] = s[n - 1];
- for (int i = 1; i < n; ++i){
- pf[i] = pf[i - 1] + (s[i]) * powp[i];
- pf[i] %= mod;
- }
- for (int i = n - 2; i >= 0; --i){
- repf[i] = repf[i + 1] + (s[i]) * powp[n - 1 - i];
- repf[i] %= mod;
- }
- if (sh){
- cout<<"pf\n";
- cvl(pf);
- cout<<"repf\n";
- cvl(repf);
- cout<<"powp\n"; cvl(powp);
- }
- for (int k = 1; k <= n/2; ++k){
- ll re, to,del=0;
- re = repf[n - k] * powp[n - k] % mod;
- if (n - 2*k - 1 >= 0){
- del = pf[n - 2*k - 1];
- }
- to = (pf[n - k - 1] - del + mod) % mod * powp[n - 1 - (n - k - 1)] % mod;
- if (sh){
- cout<<"k = "<<k<<"\n";
- cout<<"re = "<<re<<"\n";
- cout<<"to = "<<to<<"\n";
- cout<<"del = "<<del<<"\n";
- cout<<"pf[n - k - 1] = "<<pf[n - k - 1]<<"\n";
- cout<<"n - 1 - (n - k - 1) = "<<n - 1 - (n - k - 1)<<"\n";
- cout<<"powp[n - 1 - (n - k - 1)] = "<<powp[n - 1 - (n - k - 1)]<<"\n";
- }
- if (re == to){
- ans.push_back(n - k);
- }
- }
- sort(ans.begin(), ans.end());
- cv(ans);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement