今天做的沈阳站重现赛,自己还是太水,只做出两道签到题,另外两道看懂题意了,但是也没能做出来。
1、
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.1 #include <iostream> 2 3 #include <cstdio> 4 5 6 7 using namespace std; 8 9 10 11 int main(){ 12 13 int n; 14 15 int a,b; 16 17 int maxx; 18 19 int minn; 20 21 int ans; 22 23 scanf("%d",&n); 24 25 for(int j=0;j<n;j++){ 26 27 scanf("%d %d",&a,&b); 28 29 int maxx=a>b?a:b; 30 31 int minn=a>b?b:a; 32 33 int ans=maxx*2+minn; 34 35 printf("%d ",ans); 36 37 } 38 39 return 0; 40 41 }
2、
Relative atomic mass
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
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 12of 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.
Input
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.
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 #include <iostream> 2 3 #include <cstdio> 4 5 #include <cstring> 6 7 8 9 using namespace std; 10 11 12 13 int main(){ 14 15 int n; 16 17 int ans=0; 18 19 char a[20]; 20 21 scanf("%d",&n); 22 23 for(int j=0;j<n;j++){ 24 25 ans=0; 26 27 scanf("%s",a); 28 29 int len=strlen(a); 30 31 for(int i=0;i<len;i++){ 32 33 if(a[i]=='H'){ 34 35 ans+=1; 36 37 } 38 39 if(a[i]=='C'){ 40 41 ans+=12; 42 43 } 44 45 if(a[i]=='O'){ 46 47 ans+=16; 48 49 } 50 51 } 52 53 printf("%d ",ans); 54 55 } 56 57 return 0; 58 59 }
#include <iostream> #include <cstdio> #include <cstring> using namespace std; int ans=0; char graph[105][105]; int N,M,S; void fun(int i,int l){ if(l==S){ ans++; return ; }else{ for(int j=1;j<=N;j++){ if(graph[i][j]=='1'){ graph[i][j]='0'; graph[j][i]='0'; fun(j,l+1); graph[i][j]='1'; graph[j][i]='1'; } } } } int main(){ int n; int a,b; scanf("%d",&n); for(int j=0;j<n;j++){ ans=0; memset(graph,0,sizeof(graph)); scanf("%d %d %d",&N,&M,&S); for(int i=1;i<=M;i++){ scanf("%d %d",&a,&b); graph[a][b]='1'; graph[b][a]='1'; } for(int ii=1;ii<=N;ii++){ fun(ii,1); } printf("%d ",ans); } return 0; }