2016ACM/ICPC亚洲区沈阳站两道水题

Thickest Burger

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0


Problem Description
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.
<span style="font-size:24px;">#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int main(){
int n;
cin>>n;
int a,b;
while(n--)
{
    cin>>a>>b;
    int aa=max(a,b);int bb=min(a,b);

    int res=2*aa+bb;
    cout<<res<<endl;
}
return 0;}</span>
<h1 style="color: rgb(26, 92, 200); text-align: center; font-family: "Times New Roman"; margin-top: 20px;">Relative atomic mass</h1><span style="font-family:Arial;font-size: 14px; text-align: -webkit-center;"><strong><span style="font-size: 12px; color: green;">Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0
</span></strong></span><br style="font-family: "Times New Roman"; font-size: 14px; text-align: -webkit-center;" /><br style="font-family: "Times New Roman"; font-size: 14px; text-align: -webkit-center;" /><div class="panel_title" align="left" style="height: 38px; background: url("panel-title.png") left bottom no-repeat transparent; padding: 0px 14px; color: rgb(124, 169, 237); font-size: 18px; font-family: Arial; font-weight: bold;">Problem Description</div><div class="panel_content" style="height: auto; background: url("panel-content.png") repeat-y; margin: 0px; padding: 0px 20px; font-size: 14px; font-family: "Times New Roman";">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 <span class="MathJax_Preview" style="color: rgb(136, 136, 136);"></span><span class="MathJax" id="MathJax-Element-1-Frame" role="textbox" aria-readonly="true" style="display: inline; line-height: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px;"><nobr style="transition: none; border: 0px; padding: 0px; margin: 0px; max-width: none; max-height: none; min-width: 0px; min-height: 0px; vertical-align: 0px; line-height: normal;"><span class="math" id="MathJax-Span-1" style="transition: none; display: inline-block; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; width: 0.905em;"><span style="transition: none; display: inline-block; position: relative; border-top: 0px; border-right: 0px; border-bottom: 0px; border-left-style: initial; border-left-color: initial; border-image: initial; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; width: 0.836em; height: 0px; font-size: 14.42px; border-left-width: 0px !important;"><span style="transition: none; position: absolute; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; clip: rect(-0.135em 1000em 1.598em -0.621em); top: -0.967em; left: 0.003em;"><span class="mrow" id="MathJax-Span-2" style="transition: none; display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal;"><span class="mfrac" id="MathJax-Span-3" style="transition: none; display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal;"><span style="transition: none; display: inline-block; position: relative; border: 0px; padding: 0px; margin: 0px 0.142em; vertical-align: 0px; line-height: normal; width: 0.558em; height: 0px;"><span style="transition: none; position: absolute; border: 0px; padding: 0px; margin: 0px 0px 0px -0.205em; vertical-align: 0px; line-height: normal; clip: rect(1.737em 1000em 2.639em -0.551em); top: -2.84em; left: 4.01563px;"><span class="mn" id="MathJax-Span-4" style="transition: none; display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; font-size: 12px; font-family: MathJax_Main;">1</span><span style="transition: none; display: inline-block; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; width: 0px; height: 2.431em;"></span></span><span style="transition: none; position: absolute; border: 0px; padding: 0px; margin: 0px 0px 0px -0.205em; vertical-align: 0px; line-height: normal; clip: rect(1.737em 1000em 2.639em -0.551em); top: -2.008em; left: 4.01563px;"><span class="mn" id="MathJax-Span-5" style="transition: none; display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; font-size: 12px; font-family: MathJax_Main;">2</span><span style="transition: none; display: inline-block; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; width: 0px; height: 2.431em;"></span></span><span style="transition: none; position: absolute; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; clip: rect(0.836em 1000em 1.321em -0.621em); top: -1.314em; left: 0.003em;"><span style="transition: none; display: inline-block; position: static; border-width: 0px 0px 0px 0.558em; border-top-style: initial; border-right-style: initial; border-bottom-style: initial; border-left-style: solid; border-color: initial; border-image: initial; padding: 0px; margin: 0px; vertical-align: 0.003em; line-height: normal; overflow: hidden; width: 0px; height: 1.25px;"></span><span style="transition: none; display: inline-block; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; width: 0px; height: 1.113em;"></span></span></span></span></span><span style="transition: none; display: inline-block; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; width: 0px; height: 0.974em;"></span></span></span><span style="transition: none; display: inline-block; position: static; border-width: 0px 0px 0px 0.004em; border-top-style: initial; border-right-style: initial; border-bottom-style: initial; border-left-style: solid; border-color: initial; border-image: initial; padding: 0px; margin: 0px; vertical-align: -0.496em; line-height: normal; overflow: hidden; width: 0px; height: 1.504em;"></span></span></nobr></span>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 * 1 + 16.

</div><div class="panel_bottom" style="height: auto; margin: 0px; background: url("panel-bottom.png") left top no-repeat; font-family: "Times New Roman"; font-size: 14px; text-align: -webkit-center;"> </div><br style="font-family: "Times New Roman"; font-size: 14px; text-align: -webkit-center;" /><div class="panel_title" align="left" style="height: 38px; background: url("panel-title.png") left bottom no-repeat transparent; padding: 0px 14px; color: rgb(124, 169, 237); font-size: 18px; font-family: Arial; font-weight: bold;">Input</div><div class="panel_content" style="height: auto; background: url("panel-content.png") repeat-y; margin: 0px; padding: 0px 20px; font-size: 14px; font-family: "Times New Roman";">The first line of input contains one integer N(N ≤ 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.</div><div class="panel_bottom" style="height: auto; margin: 0px; background: url("panel-bottom.png") left top no-repeat; font-family: "Times New Roman"; font-size: 14px; text-align: -webkit-center;"> </div><br style="font-family: "Times New Roman"; font-size: 14px; text-align: -webkit-center;" /><div class="panel_title" align="left" style="height: 38px; background: url("panel-title.png") left bottom no-repeat transparent; padding: 0px 14px; color: rgb(124, 169, 237); font-size: 18px; font-family: Arial; font-weight: bold;">Output</div><div class="panel_content" style="height: auto; background: url("panel-content.png") repeat-y; margin: 0px; padding: 0px 20px; font-size: 14px; font-family: "Times New Roman";">For each molecule, output its relative atomic mass.</div><div class="panel_bottom" style="height: auto; margin: 0px; background: url("panel-bottom.png") left top no-repeat; font-family: "Times New Roman"; font-size: 14px; text-align: -webkit-center;"> </div><br style="font-family: "Times New Roman"; font-size: 14px; text-align: -webkit-center;" /><div class="panel_title" align="left" style="height: 38px; background: url("panel-title.png") left bottom no-repeat transparent; padding: 0px 14px; color: rgb(124, 169, 237); font-size: 18px; font-family: Arial; font-weight: bold;">Sample Input</div><div class="panel_content" style="height: auto; background: url("panel-content.png") repeat-y; margin: 0px; padding: 0px 20px; font-size: 14px; font-family: "Times New Roman";"><pre style="word-wrap: break-word; white-space: pre-wrap; margin-top: 0px; margin-bottom: 0px;"><div style="word-wrap: break-word; width: inherit; font-family: "Courier New", Courier, monospace; white-space: pre;">5
H
C
O
HOH
CHHHCHHOH</div>
 

Sample Output
  
  
1 12 16 18 46
 
<span style="font-size:24px;">#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
int main(){
int n;cin>>n;
string str;
while(n--)
{
 cin>>str;
 int len=str.length();
 int res=0;
    for(int i=0;i<len;i++)
{
    if(str[i]=='H')res+=1;
    if(str[i]=='O')res+=16;
    if(str[i]=='C')res+=12;
}
    cout<<res<<endl;
}
return 0;}</span>


 
赤裸裸的签到题,我不想多说什么。。。
                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值