链接:传送门


A - Thickest Burger - [签到水题]

ACM ICPC is launching a thick burger. The thickness (or the height) of a piece of club steak is A (1 ≤ A ≤ 100). The thickness (or the height) of a piece of chicken steak is B (1 ≤ B ≤ 100).
The chef allows to add just three pieces of meat into the burger and he does not allow to add three pieces of same type of meat. As a customer and a foodie, you want to know the maximum total thickness of a burger which you can get from the chef. Here we ignore the thickness of breads, vegetables and other seasonings.

Input
The first line is the number of test cases. For each test case, a line contains two positive integers A and B.

Output
For each test case, output a line containing the maximum total thickness of a burger.

Sample Input
10
68 42
1 35
25 70
59 79
65 63
46 6
28 82
92 62
43 96
37 28

Sample Output
178
71
165
217
193
98
192
246
235
102

Hint
Consider the first test case, since 68+68+42 is bigger than 68+42+42 the answer should be 68+68+42 = 178.
Similarly since 1+35+35 is bigger than 1+1+35, the answer of the second test case should be 1+35+35 = 71.

题意:

给出 $a,b$,输出 $\max(a+a+b,a+b+b)$。

AC代码:

#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&a,&b);
printf("%d\n",max(a+a+b,a+b+b));
}
}

B - Relative atomic mass - [签到水题]

Relative atomic mass is a dimensionless physical quantity, the ratio of the average mass of atoms of an element (from a single given sample or source) to $\frac{1}{2}$ of the mass of an atom of carbon-12 (known as the unified atomic mass unit).
You need to calculate the relative atomic mass of a molecule, which consists of one or several atoms. In this problem, you only need to process molecules which contain hydrogen atoms, oxygen atoms, and carbon atoms. These three types of atom are written as ’H’,’O’ and ’C’ repectively. For your information, the relative atomic mass of one hydrogen atom is 1, and the relative atomic mass of one oxygen atom is 16 and the relative atomic mass of one carbon atom is 12. A molecule is demonstrated as a string, of which each letter is for an atom. For example, a molecule ’HOH’ contains two hydrogen atoms and one oxygen atom, therefore its relative atomic mass is $18 = 2 \times 1 + 16$.

Input
The first line of input contains one integer $N(N \le 10)$, the number of molecules. In the next $N$ lines, the i-th line contains a string, describing the i-th molecule. The length of each string would not exceed 10.

Output
For each molecule, output its relative atomic mass.

Sample Input
5
H
C
O
HOH
CHHHCHHOH

Sample Output
1
12
16
18
46

题意:

氢元素重为 $1$,碳元素重为 $12$,氧元素重为 $16$,对输入的字符串(只包含 $C,H,O$)求和。

AC代码:

#include<bits/stdc++.h>
using namespace std;
string s;
int w[];
int main()
{
ios::sync_with_stdio();
cin.tie(); memset(w,,sizeof(w));
w['H']=;
w['C']=;
w['O']=;
int T;
cin>>T;
while(T--)
{
cin>>s;
int ans=;
for(int k=;k<s.size();k++) ans+=w[s[k]];
cout<<ans<<endl;
}
}

C - Recursive sequence - [矩阵快速幂加速递推]


E - Counting Cliques - [暴力搜索]

A clique is a complete graph, in which there is an edge between every pair of the vertices. Given a graph with N vertices and M edges, your task is to count the number of cliques with a specific size S in the graph.

Input
The first line is the number of test cases. For each test case, the first line contains 3 integers N,M and S (N ≤ 100,M ≤ 1000,2 ≤ S ≤ 10), each of the following M lines contains 2 integers u and v (1 ≤ u < v ≤ N), which means there is an edge between vertices u and v. It is guaranteed that the maximum degree of the vertices is no larger than 20.

Output
For each test case, output the number of cliques with size S in the graph.

Sample Input
3
4 3 2
1 2
2 3
3 4
5 9 3
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
6 15 4
1 2
1 3
1 4
1 5
1 6
2 3
2 4
2 5
2 6
3 4
3 5
3 6
4 5
4 6
5 6

Sample Output
3
7
15

题意:

给出一个 $n$ 个顶点 $m$ 条无向边的图,让你求图中,节点数为 $S$ 的完全图有多少个。

题解:

DFS地去找就可以了,为了保证找出来的子图没有重复,应当认为规定只能往比编号比当前节点大的节点走。

AC代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn=; int n,m,s;
int mp[maxn][maxn];
vector<int> v; vector<int> G[maxn]; int ans;
bool vis[maxn];
void dfs(int now,vector<int>& v)
{
if(v.size()==s)
{
ans++;
return;
} for(int i=;i<G[now].size();i++)
{
int nxt=G[now][i];
if(vis[nxt]) continue; bool ok=;
for(int k=;k<v.size();k++) {
if(!mp[v[k]][nxt]) {
ok=;
break;
}
}
if(ok)
{
v.push_back(nxt), vis[nxt]=;
dfs(nxt,v);
v.pop_back(), vis[nxt]=;
}
}
} int main()
{
ios::sync_with_stdio();
cin.tie(); int T;
cin>>T;
while(T--)
{
cin>>n>>m>>s; memset(mp,,sizeof(mp));
for(int i=;i<=n;i++) G[i].clear();
for(int i=,u,v;i<=m;i++)
{
cin>>u>>v;
if(u>v) swap(u,v);
if(!mp[u][v])
{
G[u].push_back(v);
mp[u][v]=mp[v][u]=;
}
} ans=;
v.clear();
memset(vis,,sizeof(vis));
for(int i=;i<=n;i++)
{
v.push_back(i), vis[i]=;
dfs(i,v);
v.pop_back(), vis[i]=;
}
cout<<ans<<'\n';
}
}

G - Do not pour out - [积分+二分] - (Done)


H - Guessing the Dice Roll - [AC自动机+高斯消元] - (Undone)


I - The Elder - [树形DP+斜率优化] - (Undone)

2016ACM/ICPC亚洲区沈阳站 - A/B/C/E/G/H/I - (Undone)的更多相关文章

  1. HDU 5950 Recursive sequence 【递推+矩阵快速幂】 (2016ACM/ICPC亚洲区沈阳站)

    Recursive sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Other ...

  2. HDU 5952 Counting Cliques 【DFS+剪枝】 (2016ACM/ICPC亚洲区沈阳站)

    Counting Cliques Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  3. HDU 5948 Thickest Burger 【模拟】 (2016ACM/ICPC亚洲区沈阳站)

    Thickest Burger Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  4. HDU 5949 Relative atomic mass 【模拟】 (2016ACM/ICPC亚洲区沈阳站)

    Relative atomic mass Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

  5. 2016ACM/ICPC亚洲区沈阳站-重现赛赛题

    今天做的沈阳站重现赛,自己还是太水,只做出两道签到题,另外两道看懂题意了,但是也没能做出来. 1. Thickest Burger Time Limit: 2000/1000 MS (Java/Oth ...

  6. 2016ACM/ICPC亚洲区沈阳站-重现赛

    C.Recursive sequence 求ans(x),ans(1)=a,ans(2)=b,ans(n)=ans(n-2)*2+ans(n-1)+n^4 如果直接就去解...很难,毕竟不是那种可以直 ...

  7. HDU 5950 - Recursive sequence - [矩阵快速幂加速递推][2016ACM/ICPC亚洲区沈阳站 Problem C]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5950 Farmer John likes to play mathematics games with ...

  8. HDU 5954 - Do not pour out - [积分+二分][2016ACM/ICPC亚洲区沈阳站 Problem G]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5954 Problem DescriptionYou have got a cylindrical cu ...

  9. 2016ACM/ICPC亚洲区沈阳站 Solution

    A - Thickest Burger 水. #include <bits/stdc++.h> using namespace std; int t; int a, b; int main ...

随机推荐

  1. CentOS7 安装FastDFS分布式文件系统

    CentOS7 安装FastDFS分布式文件系统 最近要用到fastDFS,所以自己研究了一下,在搭建FastDFS的过程中遇到过很多的问题,为了能帮忙到以后搭建FastDFS的同学,少走弯路,与大家 ...

  2. C#反射实现 C# 反射 判断类的延伸类型 使用代码生成工具Database2Sharp快速生成工作流模块控制器和视图代码 C# ADO.NET的SqlDataReader对象,判断是否包含指定字段 页面中添加锚点的几种方式 .net 简单实用Log4net(多个日志配置文件) C# 常用小点

    C#反射实现   一.反射概念: 1.概念: 反射,通俗的讲就是我们在只知道一个对象的内部而不了解内部结构的情况下,通过反射这个技术可以使我们明确这个对象的内部实现. 在.NET中,反射是重要的机制, ...

  3. 对于 url encode decode js 和 c# 有差异

    在js对一个值进行解码使用:decodeURIComponent,编码使用:encodeURIComponent

  4. CentOS 7 yum nginx MySQL PHP7 简易环境搭建(精)

    用centos自带的yum源来安装nginx,mysql和php,超级方便,省去编译的麻烦,省去自己配置的麻烦,还能节省非常多的时间. 我们先把yum源换成国内的阿里云镜像源(当然不换也可以),先备份 ...

  5. 论如何优雅的自定义ThreadPoolExecutor线程池

    更好的markDown阅读体验可直接访问我的CSDN博客:https://blog.csdn.net/u012881584/article/details/85221635 前言 线程池想必大家也都用 ...

  6. Postman 接口测试神器

    Postman 接口测试神器 Postman 是一个接口测试和 http 请求的神器,非常好用. 官方 github 地址: https://github.com/postmanlabs Postma ...

  7. Java编程的逻辑 (87) - 类加载机制

    本系列文章经补充和完善,已修订整理成书<Java编程的逻辑>,由机械工业出版社华章分社出版,于2018年1月上市热销,读者好评如潮!各大网店和书店有售,欢迎购买,京东自营链接:http:/ ...

  8. Oracle分析函数-统计(sum、avg、max、min)

    很多需求中都涉及到统计:均值.累计.范围均值.相邻记录比较等.这些操作会统计多次,或有明确的统计范围,或返回的记录统计的数据集不同... 根据场景不同可分为如下几类: 1. 全统计 2. 滚动统计 3 ...

  9. KL divergence

    Kullback-Leibler divergence 形式: 性质: 非负 P=Q时,D[P||Q]=0 不对称性:D(P||Q)≠D(Q||P) 自信息:符合分布 P 的某一事件 x 出现,传达这 ...

  10. 四大中三家已面向客户推出机器人业务解决方案?别逗了,先用机器人自我革命吧! post by 上海嘉冰信息技术

    近日,四大会计师事务所推出的机器人财务及业务解决方案的话题引爆朋友圈.鉴于该话题的前沿性以及对财务及业务领域从业人员未来职业发展有巨大的影响,引起热门讨论在所难免.小编先来汇总下目前国际四大会计师事务 ...