您现在的位置是:主页 > news > 给公司做一个网站吗/seo关键词优化举例

给公司做一个网站吗/seo关键词优化举例

admin2025/5/30 0:36:47news

简介给公司做一个网站吗,seo关键词优化举例,html5 公众号 网站开发,深圳网络科技有限公司题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id2160 解题思路: 回文树统计本质不同回文串长度,数目,降序排序后遍历。 快速幂加快乘积运算,然后碰到长度1就不用乘了。 注意本题只要奇数长度回文串。…

给公司做一个网站吗,seo关键词优化举例,html5 公众号 网站开发,深圳网络科技有限公司题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id2160 解题思路: 回文树统计本质不同回文串长度,数目,降序排序后遍历。 快速幂加快乘积运算,然后碰到长度1就不用乘了。 注意本题只要奇数长度回文串。…

题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=2160

解题思路:

回文树统计本质不同回文串长度,数目,降序排序后遍历。

快速幂加快乘积运算,然后碰到长度1就不用乘了。

注意本题只要奇数长度回文串。

代码:

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<map>
#include<set>using namespace std;#define ll long long
#define for1(i,a,b) for (int i=a;i<=b;i++)
#define for0(i,a,b) for (int i=a;i<b;i++)
#define rof1(i,a,b) for (int i=a;i>=b;i--)
#define rof0(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define fi first
#define se second
#define debug(x) printf("----Line %s----\n",#x)
#define pt(x,y) printf("%s = %d\n",#x,y)
#define INF 0x3f3f3f3f
#define df(x) ll x;scanf("%I64d",&x)
#define df2(x,y) ll x,y;scanf("%I64d %I64d",&x,&y)
#define mod 19930726
#define duozu(T) int T;scanf("%d",&T);while (T--)const int N = 1e6+5;const int maxn = 1e6+5;
const int ALP = 26;char s[N];ll fast_power(ll a,ll b)
{ll ans = 1;while (b){if (b&1) ans = ans*a%mod;b>>=1;a = a*a%mod;}return ans;
}struct node
{int len;int cnt;bool operator < (const node& a)const{return len>a.len;//降序}
}str[maxn];struct PAM{ // 每个节点代表一个回文串int next[maxn][ALP]; // next指针,参照Trie树int fail[maxn]; // fail失配后缀链接int len[maxn]; // 回文串长度int s[maxn]; // 存放添加的字符int last; //指向上一个字符所在的节点,方便下一次addint cnt[maxn];int n; // 已添加字符个数int p; // 节点个数int newnode(int w){for(int i=0;i<ALP;i++)next[p][i] = 0;len[p] = w;cnt[p] = 0;return p++;}void init(){p = 0;newnode(0);newnode(-1);last = 0;n = 0;s[n] = -1;fail[0] = 1;}int get_fail(int x){while(s[n-len[x]-1] != s[n]) x = fail[x];return x;}void add(int c){c -= 'a';s[++n] = c;int cur = get_fail(last);if(!next[cur][c]){int now = newnode(len[cur]+2);//len赋值在这fail[now] = next[get_fail(fail[cur])][c];next[cur][c] = now;}last = next[cur][c];cnt[last]++;}void count(){for (int i=p-1;i>=0;i--)cnt[fail[i]] += cnt[i];}
}pam;int main()
{int n;ll k;//被自己演了scanf("%d %lld",&n,&k);scanf("%s",s);int len = strlen(s);pam.init();for0(i,0,len) pam.add(s[i]);pam.count();int tot = 0;for1(i,2,pam.p-1){str[tot].len = pam.len[i];str[tot++].cnt = pam.cnt[i];}sort(str,str+tot);//for0(i,0,tot) printf("len=%d,cnt=%d\n",str[i].len,str[i].cnt);ll ans = 1;for0(i,0,tot){//printf("len=%d,cnt=%d\n",str[i].len,str[i].cnt);if (str[i].len&1){if (str[i].cnt<k){if (str[i].len==1){k-str[i].cnt;continue;}ans = ans*fast_power((ll)str[i].len,(ll)str[i].cnt)%mod;k -= str[i].cnt;}else {if (str[i].len==1){k = 0;break;}ans = ans*fast_power((ll)str[i].len,k)%mod;k = 0;break;}}}if (k) puts("-1");else printf("%lld\n",ans);return 0;
}

k不小心定义了int,输入虽然用了longlong但是超出范围后直接暴了,导致TLE,真想把自己头拧下来。