当前位置: 首页 > news >正文

专门做汽配的网站网站外链工具

专门做汽配的网站,网站外链工具,域名查询注册官网,怎样做网站营销文章目录 洛谷P3193 [HNOI2008] GT考试ATC abc339E Smooth SubsequenceATC abc339F Product Equality 洛谷P3193 [HNOI2008] GT考试 题目链接 KMPdp矩阵快速幂 还没有理解得很清楚&#xff0c;主要是对KMP理解还不够深刻 #include <bits/stdc.h>using namespace std;…

文章目录

  • 洛谷P3193 [HNOI2008] GT考试
  • ATC abc339E Smooth Subsequence
  • ATC abc339F Product Equality

洛谷P3193 [HNOI2008] GT考试

题目链接

KMP+dp+矩阵快速幂

还没有理解得很清楚,主要是对KMP理解还不够深刻

#include <bits/stdc++.h>using namespace std;#define int long long
using i64 = long long;typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<int, PII> PIII;
typedef pair<PII, PII> PIIII;const int N = 2010;int n, m, mod;struct Martix
{int a[30][30]; // 在这里修改矩阵的大小Martix() { memset(a, 0, sizeof(a)); }Martix operator*(const Martix &B) const // 乘法运算符重载{Martix res;for (int i = 0; i < m; i ++ )for (int j = 0; j < m; j ++ )for (int k = 0; k < m; k ++ )res.a[i][j] = (res.a[i][j] + a[i][k] * B.a[k][j]) % mod;return res;}
} G;vector<int> pi(N);
void get_pi(string s)
{int j = 0;for (int i = 2; i <= m; i++){while (j && s[j + 1] != s[i]) j = pi[j];if (s[j + 1] == s[i]) j ++ ;pi[i] = j;}for (int i = 0; i < m; i++){for (char ch = '0'; ch <= '9'; ch++){j = i;while (j && s[j + 1] != ch) j = pi[j];if (s[j + 1] == ch) j ++ ;G.a[i][j] ++ ;}}
}Martix power(Martix &a, int b)
{Martix ans;for (int i = 0; i < m; i ++ ) ans.a[i][i] = 1;while (b){if (b & 1) ans = ans * a;b >>= 1;a = a * a;}return ans;
}void solve()
{cin >> n >> m >> mod;string s; cin >> s;s = " " + s;get_pi(s);G = power(G, n);int ans = 0;for (int i = 1; i <= m; i ++ ) ans = (ans + G.a[0][i]) % mod;cout << ans << '\n';
}signed main()
{ios::sync_with_stdio(false);cin.tie(0), cout.tie(0);int t = 1;// cin >> t;while (t -- ){solve();}
}

ATC abc339E Smooth Subsequence

题目链接

线段树优化dp

把以每个数字结尾的最佳答案存进线段树中,查询即可

#include <bits/stdc++.h>using namespace std;#define int long long
using i64 = long long;typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<int, PII> PIII;const int N = 5e5 + 10;
const int mod = 1e9 + 7;struct Node
{int l, r, maxx;
} tr[N * 4];void pushup(Node &u, Node &left, Node &right)
{u.maxx = max(left.maxx, right.maxx);
}void pushup(int u)
{pushup(tr[u], tr[u << 1], tr[u << 1 | 1]);
}void build(int u, int l, int r)
{tr[u] = {l, r, 0};if (l == r) return;int mid = l + r >> 1;build(u << 1, l, mid), build(u << 1 | 1, mid + 1, r);
}void modify(int u, int pos, int x)
{if (tr[u].l == pos && tr[u].r == pos){tr[u].maxx = x;return;}int mid = tr[u].l + tr[u].r >> 1;if (pos <= mid) modify(u << 1, pos, x);else modify(u << 1 | 1, pos, x);pushup(u);
}Node query(int u, int l, int r)
{if (tr[u].l >= l && tr[u].r <= r) return tr[u];int mid = tr[u].l + tr[u].r >> 1;if (r <= mid) return query(u << 1, l, r);else if (l > mid) return query(u << 1 | 1, l, r);else{auto left = query(u << 1, l, mid);auto right = query(u << 1 | 1, mid + 1, r);Node res = {l, r};pushup(res, left, right);return res;}
}void solve()
{int n, d;cin >> n >> d;build(1, 1, N);vector<int> dp(n + 1);for (int i = 1; i <= n; i ++ ){int x;cin >> x;Node res = query(1, x - d, x + d);dp[i] = max((i64)1, res.maxx + 1);modify(1, x, dp[i]);}int ans = 0;for (int i = 1; i <= n; i ++ ){ans = max(ans, dp[i]);}cout << ans << '\n';
}signed main()
{ios::sync_with_stdio(false);cin.tie(0), cout.tie(0);int t = 1;// cin >> t;while (t -- ){solve();}
}

ATC abc339F Product Equality

题目链接

哈希

这里的一个trick是,乘积的个数比较少,哈希之后很可能出现一样的关键字,此时可以进行双哈希(或更多的哈希都没问题),取不同的模数,减小出现相同关键字的概率

#include <bits/stdc++.h>using namespace std;#define int long long
using i64 = long long;typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<int, PII> PIII;const int N = 5e5 + 10;
const int mod1 = 954169327;
const int mod2 = 906097321;void solve()
{int n;cin >> n;vector<string> a(n);map<int, int> mp1, mp2;auto mm = [&](string s, int mod){int res = 0;for (auto t : s){res = (res * 10 + t - '0') % mod;}return res;};vector<int> b1(n), b2(n);for (int i = 0; i < n; i ++ ){cin >> a[i];b1[i] = mm(a[i], mod1);mp1[b1[i]] ++ ;b2[i] = mm(a[i], mod2);mp2[b2[i]] ++ ;}int ans = 0;for (int i = 0; i < n; i ++ ){for (int j = 0; j < n; j ++ ){ans += min(mp1[(b1[i] * b1[j]) % mod1], mp2[(b2[i] * b2[j]) % mod2]);}}cout << ans << '\n';
}signed main()
{ios::sync_with_stdio(false);cin.tie(0), cout.tie(0);int t = 1;// cin >> t;while (t -- ){solve();}
}
http://www.rdtb.cn/news/16566.html

相关文章:

  • 网络运营商包括哪些产品seo是什么意思
  • 专业的营销型网站广告推送平台
  • 企业如何实现高端网站建设百度指数使用方法
  • 网页设计主题及图片seo关键词优化方法
  • 单页导航网站模板合肥品牌seo
  • 公司网站建设多少钱2022年最新最有效的营销模式
  • 亦庄网站开发国际足联世界排名
  • wordpress 电话杭州seo博客
  • 上海做网站的公司哪家好国内免费建站平台
  • 重庆聚百思网站开发武汉网络营销推广
  • 邢台高端网站建设百度小说搜索风云榜总榜
  • 怎样用java做门户网站百度一下 你知道首页
  • 印刷东莞网站建设技术支持seo广告投放
  • 呼市品牌网站建设那家好周口seo推广
  • wordpress公众号导航主题舟山百度seo
  • 福州网站制作服务线上广告投放方式
  • 中学生网站作品做一个微信小程序需要多少钱
  • 做网站送的手机站是什么营销网店推广的软文
  • wordpress评论怎么去掉网址想找搜索引擎优化
  • 做二手家电网站怎样手机版怎么用百度快照
  • 网站建设公司彩铃泽成seo网站排名
  • 海阳市住房和城乡建设局官方网站信息流广告优秀案例
  • 宁晋网站建设多少钱360免费做网站
  • wordpress 文章保存在哪里广州seo优化外包服务
  • 政府网站建设明细报价表免费正规大数据查询平台
  • 做跨境电商网站报价网站流量统计分析的维度包括
  • 柳州做网站人员百度收录量
  • 网站建设企业建站网上营销模式
  • 济南建设网站 概况外国黄冈网站推广平台
  • 网站建设的技术问题世界杯比分