链接:传送门


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代码:

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int a,b;
  4. int main()
  5. {
  6. int T;
  7. scanf("%d",&T);
  8. while(T--)
  9. {
  10. scanf("%d%d",&a,&b);
  11. printf("%d\n",max(a+a+b,a+b+b));
  12. }
  13. }

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代码:

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string s;
  4. int w[];
  5. int main()
  6. {
  7. ios::sync_with_stdio();
  8. cin.tie();
  9.  
  10. memset(w,,sizeof(w));
  11. w['H']=;
  12. w['C']=;
  13. w['O']=;
  14. int T;
  15. cin>>T;
  16. while(T--)
  17. {
  18. cin>>s;
  19. int ans=;
  20. for(int k=;k<s.size();k++) ans+=w[s[k]];
  21. cout<<ans<<endl;
  22. }
  23. }

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代码:

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const int maxn=;
  4.  
  5. int n,m,s;
  6. int mp[maxn][maxn];
  7. vector<int> v;
  8.  
  9. vector<int> G[maxn];
  10.  
  11. int ans;
  12. bool vis[maxn];
  13. void dfs(int now,vector<int>& v)
  14. {
  15. if(v.size()==s)
  16. {
  17. ans++;
  18. return;
  19. }
  20.  
  21. for(int i=;i<G[now].size();i++)
  22. {
  23. int nxt=G[now][i];
  24. if(vis[nxt]) continue;
  25.  
  26. bool ok=;
  27. for(int k=;k<v.size();k++) {
  28. if(!mp[v[k]][nxt]) {
  29. ok=;
  30. break;
  31. }
  32. }
  33. if(ok)
  34. {
  35. v.push_back(nxt), vis[nxt]=;
  36. dfs(nxt,v);
  37. v.pop_back(), vis[nxt]=;
  38. }
  39. }
  40. }
  41.  
  42. int main()
  43. {
  44. ios::sync_with_stdio();
  45. cin.tie();
  46.  
  47. int T;
  48. cin>>T;
  49. while(T--)
  50. {
  51. cin>>n>>m>>s;
  52.  
  53. memset(mp,,sizeof(mp));
  54. for(int i=;i<=n;i++) G[i].clear();
  55. for(int i=,u,v;i<=m;i++)
  56. {
  57. cin>>u>>v;
  58. if(u>v) swap(u,v);
  59. if(!mp[u][v])
  60. {
  61. G[u].push_back(v);
  62. mp[u][v]=mp[v][u]=;
  63. }
  64. }
  65.  
  66. ans=;
  67. v.clear();
  68. memset(vis,,sizeof(vis));
  69. for(int i=;i<=n;i++)
  70. {
  71. v.push_back(i), vis[i]=;
  72. dfs(i,v);
  73. v.pop_back(), vis[i]=;
  74. }
  75. cout<<ans<<'\n';
  76. }
  77. }

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. Transport scheme NOT recognized: [stomp]

    今天在ubuntu上装个activemq,本来以为就是apt-get install activemq就行了的. 结果配置上stomp协议,activemq居然起不来.起不来就起不来吧,也没个提示. ...

  2. golang 使用pprof和go-torch做性能分析

    软件开发过程中,项目上线并不是终点.上线后,还要对程序的取样分析运行情况,并重构现有的功能,让程序执行更高效更稳写. golang的工具包内自带pprof功能,使找出程序中占内存和CPU较多的部分功能 ...

  3. 优麒麟 16.04 LTS(长期支持)版本

    Ubuntu Kylin (中文又被称为优麒麟)是基于Ubuntu的一款官方衍生版. 它是一款专门为中国市场打造的免费操作系统.它包括Ubuntu用户期待的各种功能,并配有必备的中文软件及程序. ht ...

  4. [转]The Production Environment at Google

    A brief tour of some of the important components of a Google Datacenter.   A photo of the interior o ...

  5. Android Studio创建JAR/AAR库

    [时间:2017-09] [状态:Open] [关键词:Android,Android Studio,gradle,jar,aar,library] 0 引言 最近在工作中遇到了升级Android S ...

  6. [转]论SOA架构的几种主要开发方式

    面向服务架构soa以其独特的优势越来越受到企业的重视,它可以根据需求通过网络对松散耦合的粗粒度应用组件进行分布式部署.组合和使用.服务层是SOA的基础,可以直接被应用调用,从而有效控制系统中与软件代理 ...

  7. 【C#】读取Excel中嵌套的Json对象,Json带斜杠的问题(其三)

    除了上一篇中提到的对字符串的字符替换操作,去掉Json中的转义符反斜杠\之外,还发现了更加简单的办法. 就是使用Newtownsoft.Json序列化Json时,将嵌套的Json对象(字符串)转为JO ...

  8. Golang学习教程

    字节跳动已经全线从Python转Golang了,可能开始学习Golang这门语言会觉得无所适从,和Java,C++,Python等都不大一样,但是用多了会发现这门语言设计的还是很优雅的,下面总结Gol ...

  9. 【规范】前端编码规范——css 规范

    编码 在 css 首行设置文件编码为 UTF-8. @charset "UTF-8"; class 命名 class 名称应当尽可能短,并且意义明确.使用有意义的名称,使用有组织的 ...

  10. shell md5sum

    md5sum  out.a echo "fd_limit=$(ulimit -n), fd_used=$(ll /proc/4741/fd | wc -l)"   需找句柄,及fd ...