2020牛客暑期多校训练营(第一场)
文章目录
- A B-Suffix Array
- B Infinite Tree
- C Domino
- D Quadratic Form
- E Counting Spanning Trees
- F Infinite String Comparision
- 题意:
- 题解:
- 代码:
- G BaXianGuoHai, GeXianShenTong
- H Minimum-cost Flow
- I 1 or 2
- J Easy Integration
- 题意
- 题解
- 代码
2020牛客暑期多校训练营(第一场)
A B-Suffix Array
B Infinite Tree
C Domino
D Quadratic Form
E Counting Spanning Trees
F Infinite String Comparision
题意:
两个字符串A和B,对AAAA…和BBBB…(字符串A和B无限重复)进行比较,输出 > = <
题解:
方法一:
字符串a和b从第一位开始比较,当比到其中最后一位时再跳转到第一位继续。那什么时候算等于呢,我一开始想的是a和b的最小公倍数,这样会超时,我们其实只需比较较长字符串的两倍即可。因为如果两个字符串不相等,那么在较长字符串的两倍范围内必将可以必出大小关系
方法二:
很简单,比较a+b和b+a的大小关系,直接输出
如果a和b相等,那么a+b肯定==b+a,否则两者肯定能必出大小
代码:
方法一:
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <cstring>
#include <stdio.h>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>#define MAX 1000010using namespace std;typedef long long ll;char a[MAX];
char b[MAX];int main(){while(~scanf("%s %s",a,b)){int la=strlen(a);int lb=strlen(b);ll l=max(la,lb)*2;int ia=0,ib=0;int flag=0;for(ll i=0;i<l;i++){if(a[ia]>b[ib]){printf(">\n");flag=1;break;}else if(a[ia]<b[ib]){printf("<\n");flag=-1;break;}else {ia++;ib++;if(ia==la)ia=0;if(ib==lb)ib=0;}}if(flag==0){printf("=\n");}}return 0;
}
方法二:
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>using namespace std;using Int = long long;template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }char S[100010];
char T[100010];int main() {for (; ~scanf("%s%s", S, T); ) {const string s = S;const string t = T;const string st = s + t;const string ts = t + s;puts((st < ts) ? "<" : (st > ts) ? ">" : "=");}return 0;
}
G BaXianGuoHai, GeXianShenTong
H Minimum-cost Flow
I 1 or 2
J Easy Integration
题意
对于一个n,求出的值,结果可以写成p/q的形式,最后输出 (p⋅q −1 )mod998244353 的值
题解
沃利斯公式
直接有公式,带入计算就行
代码
#include<bits/stdc++.h>
using namespace std;const int manx=2e6+5;
const int N=1e3+5;
const int mod=998244353;ll dp[manx],n;
ll poww(ll a, ll b){ll ans=1;while(b){if(b&1) ans=ans*a%mod;a=a*a%mod;b>>=1;}return ans%mod;
}
ll inv(ll x){return poww(x,mod-2);
}
int main()
{dp[1]=1;for(int i=2;i<=2000005;i++) dp[i]=dp[i-1]*i%mod;while(cin>>n){ll ans=dp[n]*dp[n]%mod*inv(dp[2*n+1])%mod;cout<<ans<<endl;}return 0;
}
2020牛客暑期多校训练营(第一场)相关推荐
- 2020牛客暑期多校训练营(第九场)E题 Groundhog Chasing Death
题意 计算 ∏ i = a b ∏ j = c d g c d ( x i , y j ) \prod_{i=a}^{b}\prod_{j=c}^{d}gcd(x^i,y^j) i=a∏bj=c∏d ...
- 2020牛客暑期多校训练营(第六场)
2020牛客暑期多校训练营(第六场) 额,睡了一下午,直接错过了比赛... 文章目录 A African Sort 题意: 题解: 代码: B Binary Vector C Combination ...
- 2020牛客暑期多校训练营(第四场)
2020牛客暑期多校训练营(第四场) 这场属实有点难受 文章目录 A Ancient Distance B Basic Gcd Problem 题目 代码: C Count New String D ...
- 2020牛客暑期多校训练营(第二场)
2020牛客暑期多校训练营(第二场) 最烦英语题 文章目录 A All with Pairs B Boundary C Cover the Tree D Duration E Exclusive OR ...
- 2020牛客暑期多校训练营(第七场)J.Pointer Analysis
2020牛客暑期多校训练营(第七场)J.Pointer Analysis 题目链接 题目描述 Pointer analysis, which aims to figure out which obje ...
- 2020牛客暑期多校训练营(第三场)A.Clam and Fish
2020牛客暑期多校训练营(第三场)A.Clam and Fish 题目链接 题目描述 There is a fishing game as following: The game contains ...
- 2020牛客暑期多校训练营(第五场)——E Bogo Sort
2020牛客暑期多校训练营(第五场)--E Bogo Sort 题目描述 Today Tonnnny the monkey learned a new algorithm called Bogo So ...
- E Groundhog Chasing Death(2020牛客暑期多校训练营(第九场))(思维+费马小定理+质因子分解)
E Groundhog Chasing Death(2020牛客暑期多校训练营(第九场))(思维+费马小定理+质因子分解) 链接:https://ac.nowcoder.com/acm/contest ...
- 2020牛客暑期多校训练营(第一场)A B-Suffix Array(后缀数组,思维)
链接:https://ac.nowcoder.com/acm/contest/5666/A 来源:牛客网 题目描述 The BBB-function B(t1t2-tk)=b1b2-bkB(t_1 t ...
最新文章
- 中国在科技领域崛起 美国人的保护主义蠢蠢欲动
- Container View Controller
- 【数据结构与算法】Treap的Java实现
- 【Kafka】kafka NotLeaderForPartitionException thisserver is not the leader for topic-partition
- java spark命令行执行参数
- Axure RP 9的安装与汉化
- Android进阶学习方法总结(内附阿里P7进阶学习全套资料)
- 禾赛科技2022数字芯片提前批笔试
- 条件概率、全概率公式和贝叶斯公式
- linux下脚本录制工具——script和scriptreplay
- 洛谷 P4233 射命丸文的笔记 ntt
- 懈寄生---走出软件作坊:三五个人十来条枪 如何成为开发正规军(十四)
- 【​观察】以双引擎动态技术破局,瑞数信息再定义传统WAF市场
- linux服务器重启原因排查_Linux自动重启排查
- 数字式调频收音机设计
- Linux搭建Hyperledger Fabric区块链框架 - Hyperledger Fabric模型概念
- 数学建模学习笔记(2.3)lingo软件求解线性规划问题
- 【思维进阶】人生为一件大事而来
- JDK-17的下载与安装
- 嵌入式C语言编写51单片机控制电机转速
热门文章
- 万万想不到:吸烟的辐射量比原子弹爆炸点还厉害!
- 程序员新人怎样在复杂代码中找 bug?
- c语言怎么让图形界面单独显示,「分享」C语言如何编写图形界面
- bms中soh计算方式_BMS算法设计之电池SOH介绍(下)
- aop springboot 传入参数_Springboot添加AOP打印请求参数
- 机器学习之琐碎知识(代码运行问题)
- 算法题目——Problem A 二进制(北邮机试)
- 10-5 5-5 查询只卖三种不同型号PC的厂商 (20 分)
- libgo 支持mysql,loadrunner通过使用libmysql.dll完成mysql的测试-Go语言中文社区
- 辅助类BinaryTreeNode(二叉树节点)