2018CCPC-女生专场
(咕咕咕,咕了快一年的bu题。。
A.CCPC直播
传送:http://acm.hdu.edu.cn/showproblem.php?pid=6297
题意:rt。
分析:模拟。
#include<bits/stdc++.h>
using namespace std;
int main(){
int t; scanf("%d",&t);
while (t--){
int pro,num; string rank,name,now;
cin >> rank;
cin >> name;
cin >> pro;
cin >> now;
if (now=="Running") cin >> num;
for (int i=;i<-rank.size();i++) cout << " ";
cout << rank << "|";
cout << name;
for (int i=;i<-name.size();i++) cout << " ";
cout << "|";
cout << pro << "|[";
if (now=="Running"){
for (int i=;i<num;i++) cout << "X";
for (int i=;i<-num;i++) cout << " ";
}
else{
for (int i=;i<;i++) cout << " ";
if (now=="FB"){
cout << "AC*";
for (int i=;i<;i++) cout << " ";
}
else{
cout << now;
for (int i=;i<-now.size()-;i++) cout << " ";
}
}
cout << "]\n";
}
return ;
}
P6297
B.口算训练
传送:http://acm.hdu.edu.cn/showproblem.php?pid=6287
题意:T(T<=10)组数据。给定n(n<=1e5)个数,a1,a2,....an(ai<=1e5)。m(m<=1e5)个询问,询问在区间[l,r[内所有数的乘积是否为k(k<=1e5)的倍数。
分析:(卡住了。。wsl
C.缺失的数据范围
传送:http://acm.hdu.edu.cn/showproblem.php?pid=6288
题意:求解最大的正整数n,满足公式:
。数据范围:1<=a,b<=10,1e6<=k<=1e18。
分析:要求取得尽可能大的n。所以可以二分答案一直找尽可能大的n。注意,在check函数内,使用库函数log会有精度损失,需要手写log并上取整。
另,1e18相乘会爆ll,需要先除再比较大小。(wa了n发的坑点。。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll _log(ll n){
ll ans=;
while (){
if (n==) return ans;
else if (n==) return ans+;
n-=n/;
ans++;
}
}
bool check(ll xx,int a,int b,ll k){
ll tmp=_log(xx);
ll num=;
while (a--){
if (num*tmp>k) return false;
num*=xx;
}
while (b--){
if (num*tmp>k) return false;
num*=tmp;
}
return true;
}
int main(){
int t; scanf("%d",&t);
int a,b; ll k,ans;
while (t--){
scanf("%d%d%I64d",&a,&b,&k);
ll l=,r=k,mid;
while (l<=r){
mid=(l+r)/;
if (check(mid,a,b,k)){
ans=mid; l=mid+;
}
else r=mid-;
}
printf("%I64d\n",ans);
}
return ;
}
P6288
D.
E.奢侈的旅行
传送:http://acm.hdu.edu.cn/showproblem.php?pid=6290
题意:n个点,m条单向路,每条路的描述为(u,v,a,b)。初始等级为1,通过每条路的要求为:通过这条路的花费为cost=
,那么只有满足:
时,才可以通过这条路。并且level提升a。问从1--n的最小花费。
分析:对于每一条边的通过限制条件,经过简单处理可以变成:
。同时,对于每一次的花费相加(底数相同的log相加,真数相乘),化简之后可以变成:
。所以在跑最短路时可以直接用ll来做,避免因为double的精度所导致的错误。
dijk+堆优化。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+;
const double inf=2e18;
struct edge{
int to;
ll a,b;
};
vector<edge> mp[maxn];
struct node{
int to; ll cost;
friend bool operator < (node p,node q){
return p.cost>q.cost;
}
};
int n,m;
bool vis[maxn]; ll dist[maxn];
void dijk(){
priority_queue<node> q;
for (int i=;i<=n;i++) vis[i]=false,dist[i]=inf;
q.push({,1.0});
dist[]=;
while (!q.empty()){
node tmp=q.top(); q.pop();
if (vis[tmp.to]) continue;
vis[tmp.to]=true;
for (int i=;i<mp[tmp.to].size();i++){
edge res=mp[tmp.to][i];
if (dist[res.to]>dist[tmp.to]+res.a && (dist[tmp.to]+res.a)/dist[tmp.to]>=(1ll<<res.b)){
dist[res.to]=dist[tmp.to]+res.a;
q.push({res.to,dist[res.to]});
}
}
}
}
int main(){
int t; scanf("%d",&t);
int u,v; ll a,b;
while (t--){
scanf("%d%d",&n,&m);
for (int i=;i<=n;i++) mp[i].clear();
for (int i=;i<m;i++){
scanf("%d%d%lld%lld",&u,&v,&a,&b);
mp[u].push_back({v,a,b});
}
dijk();
if (dist[n]==inf){
printf("-1\n"); continue;
}
int num=;
while (dist[n]){
dist[n]/=;
++num;
}
printf("%d\n",num-);
}
return ;
}
P6290
F.对称数
传送:
题意:
分析:
G.赛题分析
传送:http://acm.hdu.edu.cn/showproblem.php?pid=6292
题意:rt。
分析:模拟。
#include<bits/stdc++.h>
using namespace std;
int main(){
int t,n,m,x; scanf("%d",&t);
int _=;
while (t--){
scanf("%d%d",&n,&m);
printf("Problem %d:\n",++_);
int ans=1e5;
for (int i=;i<n;i++){
scanf("%d",&x);
ans=min(ans,x);
}
printf("Shortest judge solution: %d bytes.\n",ans);
ans=1e5;
for (int i=;i<m;i++){
scanf("%d",&x);
ans=min(ans,x);
}
if (m!=) printf("Shortest team solution: %d bytes.\n",ans);
else printf("Shortest team solution: N/A bytes.\n");
}
return ;
}
P6292
H.
I.SA-IS后缀数组
传送:http://acm.hdu.edu.cn/showproblem.php?pid=6294
题意:有一个长度为n的字符串,定义Si为以第i个字母开始的字符串后缀。求问,对于1<=i<n,Si与Si+1的字典序大小。
分析:思考一下。发现,只需要判断当前字符和下一个字符的大小关系即可,如果相同,就继续比较下一个位置。从后往前做即可。
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+;
char s[maxn],ans[maxn];
int main(){
int t,n; scanf("%d",&t);
while (t--){
scanf("%d",&n);
scanf("%s",s);
ans[n-]='>';
for (int i=n-;i>=;i--){
if (s[i]>s[i+]) ans[i]='>';
else if (s[i]<s[i+]) ans[i]='<';
else ans[i]=ans[i+];
}
for (int i=;i<n-;i++) printf("%c",ans[i]);
printf("\n");
}
return ;
}
P6294
J.回文树
传送:http://acm.hdu.edu.cn/showproblem.php?pid=6295
题意:有n个结点的树,每个点有一个值a[i],且a[i]的取值为1--n内随机的。求问,对于任意一对结点<u,v>,表示从u到v的树上的最短路径,路径上依此所经过的数字是回文串的点对数。
分析:因为ai取值随机。那么直接枚举回文串的中心即可(中心可以为点,也可以为一条边)。然后向两边不断扩展暴力即可。
同时注意题目中的限制条件,要求1<=u<=v<=n。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+;
vector<int> mp[maxn];
int a[maxn];
bool cmp(int p,int q){return a[p]<a[q] || a[p]==a[q] && p<q;}
ll ans;
void dfs(int x,int fx,int y,int fy){
if (a[x]!=a[y]) return ;
if (fx!= && x==y) return ;
if (x<=y) ans++;
int j=,k;
for (int i=;i<mp[x].size();i++){
if (mp[x][i]!=fx){
while (j<mp[y].size() && a[mp[y][j]]<a[mp[x][i]]) j++;
k=j;
while (k<mp[y].size() && a[mp[y][k]]<=a[mp[x][i]]) k++;
for (int t=j;t<k;t++)
if (mp[y][t]!=fy) dfs(mp[x][i],x,mp[y][t],y);
}
}
}
int main(){
int t,n,x,y; scanf("%d",&t);
while (t--){
scanf("%d",&n);
for (int i=;i<=n;i++) scanf("%d",&a[i]),mp[i].clear();
ans=;
for (int i=;i<n-;i++){
scanf("%d%d",&x,&y);
mp[x].push_back(y);
mp[y].push_back(x);
}
for (int i=;i<=n;i++) sort(mp[i].begin(),mp[i].end(),cmp);
for (int i=;i<=n;i++) dfs(i,,i,); //点作为回文中心
for (int i=;i<=n;i++){
for (int j=;j<mp[i].size();j++){
dfs(i,mp[i][j],mp[i][j],i); //边作为回文中心
}
}
printf("%lld\n",ans);
}
return ;
}
P6295
K.
2018CCPC-女生专场的更多相关文章
- HDU 6024(中国大学生程序设计竞赛女生专场1002)
这是CCPC女生专场的一道dp题.大佬们都说它简单,我并没有感到它有多简单. 先说一下题意:在一条直线上,有n个教室,现在我要在这些教室里从左到右地建设一些作为糖果屋,每个教室都有自己的坐标xi 和建 ...
- 2017中国大学生程序设计竞赛 - 女生专场 Deleting Edges(思维+最短路)
Deleting Edges Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- 2017中国大学生程序设计竞赛 - 女生专场 Happy Necklace(递推+矩阵快速幂)
Happy Necklace Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- 2017中国大学生程序设计竞赛 - 女生专场(Graph Theory)
Graph Theory Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)To ...
- 2017中国大学生程序设计竞赛 - 女生专场(dp)
Building Shops Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) To ...
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场
Combine String #include<cstdio> #include<cstring> #include<iostream> #include<a ...
- hdu_5705_Clock("巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5705 题意:给你一个时间和一个角度,问你下一个时针和分针形成给出的角度是什么时候 题解:我们可以将这个 ...
- hdu_5707_Combine String("巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5707 题意:给你三个字符串 a,b,c,问你 c能否拆成a,b,a,b串的每一个字符在c中不能变 题解 ...
- 2018CCPC女生赛(树上莫队)
签到题这里久懒得写了. B - 缺失的数据范围 Total Submission(s): 2602 Accepted Submission(s): 559 题意:求最大的N,满足N^a*[log ...
- "字节跳动杯"2018中国大学生程序设计竞赛-女生专场 Solution
A - 口算训练 题意:询问 $[L, R]$区间内 的所有数的乘积是否是D的倍数 思路:考虑分解质因数 显然,一个数$x > \sqrt{x} 的质因子只有一个$ 那么我们考虑将小于$\sqr ...
随机推荐
- django 过滤器,标签
过滤器: <p>{{ date|date:"Y-m-d" }}</p> {#2018-05-28,date是当前时间#} <p>{{ l|len ...
- Flink架构、原理与部署测试(转)
Apache Flink是一个面向分布式数据流处理和批量数据处理的开源计算平台,它能够基于同一个Flink运行时,提供支持流处理和批处理两种类型应用的功能. 现有的开源计算方案,会把流处理和批处理作为 ...
- 大数据入门到精通14--hive 对 字符串的操作
一.基本操作 concat(string,string,string)concat_ws(string,string,string)select customer_id,concat_ws(" ...
- java学习笔记(二):枚举值
枚举值的作用:枚举限制了变量要有一些预先定义的值,运用枚举值可以大大减少你的代码中的漏洞,举例来说,如果我们想为一家鲜榨果汁店编个程序,就可以将杯子的尺寸限制为小中和大.这样就可以确保人们不会定大中小 ...
- oracle数据库分页总结
/* BEGIN CREATE TABLE APPUSER(IDS NUMBER(8), USERNAME VARCHAR2(20), PASSWORD VARCHAR2(20), CTIME DAT ...
- 259. 3Sum Smaller小于版3sum
[抄题]: Given an array of n integers nums and a target, find the number of index triplets i, j, k with ...
- [leetcode]205. Isomorphic Strings 同构字符串
Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the chara ...
- CRM中QueryDict和模型表知识补充
CRM中QueryDict和模型表知识补充 1.QueryDict的用法 request.GET的用法:1.在页面上输入:http://127.0.0.1:8000/index/print(reque ...
- 设置angular公共样式表
一.现象 新创建的项目,是直接显示在src目录下的,假如会用到其它第三方的全局样式时,不能统一放在一个地方统一来管理,就会感觉有点乱. 二.解决 1.移动样式表. 在assets文件夹(该文件夹一般都 ...
- application/json和application/x-www-form-urlencoded使用选择
一.参考资料 选application/x-www-form-urlencoded还是application/json? @RequestBody应用 二.理解 1.@RequestBody的作用 注 ...