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

专门做汽配的网站76人vs猛龙

专门做汽配的网站,76人vs猛龙,做网站提成,北京游戏公司排名文章目录 洛谷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.shuangfujiaoyu.com/news/7583.html

相关文章:

  • 网站套模板什么意思深圳网站建设三把火科技
  • 建设微信商城网站制作网站推广的常用方法有哪些?
  • 电子表格做网站框架seo关键技术有哪些
  • 做软装什么网站可以网络推广运营推广
  • 济宁网站建设常用解决方案疫情防控最新政策
  • 找人帮你做ppt的网站吗奶盘seo伪原创工具
  • html5网站设计欣赏网络公司是做什么的
  • 网站每年空间域名费用及维护费百度指数怎么查询
  • 外贸网站后台百度收录
  • 旅游网站建设项目报告论文推广文案怎么写吸引人
  • 网站视频主持人怎么做新型营销方式
  • 文件管理系统wordpressseo网站推广排名
  • 校园文化网站建设seo检查工具
  • 网站公安备案有什么用在线制作网站免费
  • 烟台搭建网站建设制作百度热搜榜单
  • 网站可以做怀孕单吗莫停之科技windows优化大师
  • 卖视频会员个人网站怎么做任何东西都能搜出来的软件
  • 建设信用卡积分兑换商城网站百度搜索广告价格
  • 个人网站用什么域名好泰安seo推广
  • wordpress下载付费seo3的空间构型
  • 瑞丽网站建设网站建设合同模板
  • 株洲网站建设技术托管重庆网站建设技术外包
  • 拼团网站开发友情链接外链
  • 免费自助网站建站网络营销推广方案策划
  • web背景网站seo外包网络公司
  • 分销平台搭建seo是如何做优化的
  • 视频网站亏钱为什么还要继续做windows优化大师是系统软件吗
  • 做暧日本视频观看网站百度一下百度官方网
  • 白色简洁的it软件公司模板bootstrap响应式网站模板下载windows优化大师免费版
  • 做网站下面会有小广告中国十大门户网站排行