ACM Shenyang Onsite 2016 题目
A. Thickest Burger
- 1000ms
- 262144K
ACM ICPC is launching a thick burger. The thickness (or the height) of a piece of club steak is AAA (1≤A≤100)(1 \le A \le 100)(1≤A≤100). The thickness (or the height) of a piece of chicken steak is BBB (1≤B≤100)(1 \le B \le 100)(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 AAA and BBB.
Output
For each test case, output a line containing the maximum total thickness of a burger.
Consider the first test case, since 68+68+4268+68+4268+68+42 is bigger than 68+42+4268+42+4268+42+42 the answer should be 68+68+42=17868+68+42 = 17868+68+42=178. Similarly since 1+35+351+35+351+35+35 is bigger than 1+1+351+1+351+1+35, the answer of the second test case should be 1+35+35=711+35+35 = 711+35+35=71.
样例输入
10
68 42
1 35
25 70
59 79
65 63
46 6
28 82
92 62
43 96
37 28
样例输出
178
71
165
217
193
9
192
246
235
102
思路:简单~
代码:
1 #include<bits/stdc++.h>
2 using namespace std;
3
4 int main()
5 {
6 int n;
7 int a,b;
8 cin>>n;
9 while(n--)
10 {
11 cin>>a>>b;
12 int sum=0;
13 if(a>b)
14 {
15 sum=2*a+b;
16 }
17 else
18 {
19 sum=2*b+a;
20 }
21 cout<<sum<<endl;
22 }
23 return 0;
24 }
B. Relative atomic mass
- 1000ms
- 262144K
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 112\tfrac{1}{12}121 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 ’HHH’, ’OOO’ and ’CCC’ repectively. For your information, the relative atomic mass of one hydrogen atom is 111, and the relative atomic mass of one oxygen atom is 161616 and the relative atomic mass of one carbon atom is 121212. 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+1618 = 2 * 1 + 1618=2∗1+16.
Input
The first line of input contains one integer N(N≤10)N(N \le 10)N(N≤10), the number of molecules.
In the next NNN lines, the iii-th line contains a string, describing the iii-th molecule. The length of each string would not exceed 101010.
Output
For each molecule, output its relative atomic mass.
样例输入
5
H
C
O
HOH
CHHHCHHOH
样例输出
1
12
16
18
46
代码:
1 #include<bits/stdc++.h>
2 using namespace std;
3 string s;
4 int main()
5 {
6 int n;
7 cin>>n;
8 while(n--)
9 {
10 cin>>s;
11 int len=s.length();
12 int sum=0;
13 for(int i=0;i<len;i++)
14 {
15 if(s[i]=='H')
16 {
17 sum+=1;
18 }
19 else if(s[i]=='C')
20 {
21 sum+=12;
22 }
23 else
24 {
25 sum+=16;
26 }
27 }
28 cout<<sum<<endl;
29
30 }
31 return 0;
32 }
C. Recursive sequence
- 1000ms
- 262144K
Farmer John likes to play mathematics games with his NNN cows. Recently, they are attracted by recursive sequences. In each turn, the cows would stand in a line, while John writes two positive numbers aaa and bbb on a blackboard. And then, the cows would say their identity number one by one. The first cow says the first number aaa and the second says the second number bbb. After that, the iii-th cow says the sum of twice the (i−2)(i - 2)(i−2)-th number, the (i−1)(i - 1)(i−1)-th number, and i4i^4i4. Now, you need to write a program to calculate the number of the NNN-th cow in order to check if John’s cows can make it right.
Input
The first line of input contains an integer ttt, the number of test cases. ttt test cases follow.
Each case contains only one line with three numbers NNN, aaa and bbb where N,a,b<231N,a,b < 2^{31}N,a,b<231 as described above.
Output
For each test case, output the number of the NNN-th cow. This number might be very large, so you need to output it modulo 214749364721474936472147493647.
In the first case, the third number is 85=21+2+3485 = 21+2+3^485=21+2+34. In the second case, the third number is 93=21+1∗10+3493 = 21+1*10+3^493=21+1∗10+34 and the fourth number is 369=2∗10+93+44369 = 2 * 10 + 93 + 4^4369=2∗10+93+44.
样例输入
2
3 1 2
4 1 10
样例输出
85
369
思路:矩阵快速幂+结构体,写出C*A(N-1)=A(N)。计算:C(N-1)*A(1)=A(N)或者C(N-2)*A(2)=A(N)或者C(N-3)*A(3)=A(N)...
代码:
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
const long long mod=;
const int si=;
typedef long long ll; struct mat
{
ll c[si][si];
}; mat matmul(mat a,mat b)
{
mat ans;
memset(ans.c,,sizeof ans.c);
for(int i=; i<=; i++)
{ for(int j=; j<=; j++)
{
for(int k=; k<=; k++)
{
ans.c[i][j]+=((a.c[i][k]%mod)*(b.c[k][j]%mod))%mod;
}
}
}
return ans;
} mat qpow(mat a,ll n)
{
mat ans;
memset(ans.c,,sizeof ans.c);
for(int i=; i<=; i++)
{
ans.c[i][i]=;
}
while(n)
{
if(n&)
{
ans=matmul(ans,a);
}
a=matmul(a,a);
n>>=;
}
return ans;
} mat init()
{
mat a;
memset(a.c,,sizeof a.c);
a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=;
a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=;
a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=;
a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=;
a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=;
a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=;
a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=,a.c[][]=;
return a; } int main()
{
ll n,t,q,w;
cin>>t;
while(t--)
{
cin>>n>>q>>w;
mat b;
b.c[][]=w,b.c[][]=q,b.c[][]=,b.c[][]=,b.c[][]=,b.c[][]=,b.c[][]=;
mat res;
res=qpow(init(),n-);
res=matmul(res,b);
printf("%lld\n",(res.c[][])%mod);
}
return ;
}
ACM Shenyang Onsite 2016 题目的更多相关文章
- ACM - 概率、期望题目 小结(临时)
概率DP求期望大多数都是全期望公式的运用.主要思考状态空间的划分以及状态事件发生的概率.问题可以分为无环和有环两类.无环一类多数比较简单,可以通过迭代或者记忆化搜索完成.有环一类略复杂,可以通过假设方 ...
- 2019浙江ACM省赛——部分题目
有一些题目过了我还没有重新写,先放一些我重新写好了的吧 签到题拿到了信心吧,9分钟写完两题,我们贼开心,我大哥说签到题有什么好开心的,如果不是我有一些地方卡了下,可能还是更快吧,还有就是测试案例多试了 ...
- 【赛后补题】(HDU6223) Infinite Fraction Path {2017-ACM/ICPC Shenyang Onsite}
场上第二条卡我队的题目. 题意与分析 按照题意能够生成一个有环的n个点图(每个点有个位数的权值).图上路过n个点显然能够生成一个n位数的序列.求一个最大序列. 这条题目显然是搜索,但是我队在场上(我负 ...
- 【赛后补题】(HDU6228) Tree {2017-ACM/ICPC Shenyang Onsite}
这条题目当时卡了我们半天,于是成功打铁--今天回来一看,mmp,贪心思想怎么这么弱智.....(怪不得场上那么多人A了 题意分析 这里是原题: Tree Time Limit: 2000/1000 M ...
- ACM学习历程—2016"百度之星" - 资格赛(Astar Round1)
http://bestcoder.hdu.edu.cn/contests/contest_show.php?cid=690 A题: 给定字符串,求任意区间的Hash值. 根据题目给定的Hash方式,属 ...
- ACM 暴力搜索题 题目整理
UVa 129 Krypton Factor 注意输出格式,比较坑爹. 每次要进行处理去掉容易的串,统计困难串的个数. #include<iostream> #include<vec ...
- ACM题目推荐(刘汝佳书上出现的一些题目)[非原创]
原地址:http://blog.csdn.net/hncqp/article/details/1758337 推荐一些题目,希望对参与ICPC竞赛的同学有所帮助. POJ上一些题目在http://16 ...
- ACM计算几何题目推荐
//第一期 计算几何题的特点与做题要领: 1.大部分不会很难,少部分题目思路很巧妙 2.做计算几何题目,模板很重要,模板必须高度可靠. 3.要注意代码的组织,因为计算几何的题目很容易上两百行代码,里面 ...
- 山东省第四届acm解题报告(部分)
Rescue The PrincessCrawling in process... Crawling failed Description Several days ago, a beast ca ...
随机推荐
- NGS检测SNP
1,Fastq数据质控 2,Fastq转化成bam,包含头文件 bwa aln ref.fa test_1.fq > test_1.sai bwa aln ref.fa test_2.fq &g ...
- linux java jdk环境变量设置之后,依旧提示 No such file or directory
今天又默默的在linux下安装java 明明是很简单的事情,在~/.bashrc中添加如下内容: export JAVA_HOME=/home/ubuntu/jdkexport CLASSPATH=. ...
- Windows和Linux下通用的线程接口
对于多线程开发,Linux下有pthread线程库,使用起来比较方便,而Windows没有,对于涉及到多线程的跨平台代码开发,会带来不便.这里参考网络上的一些文章,整理了在Windows和Linux下 ...
- Nessus 用好的网络(比如热点)就可以正常在线更新扫描插件了
折腾那么多不如直接开热点 nethogs 实时查看网络流量 ( linux下 )
- CentOS7中使用阿里云镜像
之前因为下载Docker镜像很慢所以用了一家国内的镜像DaoCloud,今天要用的是阿里云的镜像库. 首先要开通了阿里云开发者帐号,地址 : https://dev.aliyun.com/search ...
- 菜鸟vimer成长记——第4.1章、通用插件
简介 关于插件的分类,此系列只会简单的区分为通用插件和编程插件.通用插件的意思是,不基于任何编程语言都可以使用的插件.编程插件,是针对于编程习惯,或者说是针对于某种语言的插件. 计划中,是先把基本常用 ...
- 将exe依赖运行的dll,合并入exe中,整个程序仅存在一个exe文件
方法一: 使用ILMerge合并winform生成的exe和引用的dll文件 参考:https://blog.csdn.net/u010108836/article/details/76782375 ...
- spring-boot2.x Application properties属性配置
# =================================================================== # COMMON SPRING BOOT PROPERTIE ...
- SpringCloud版本问题
兴致勃勃地跟随文档创建并配置Eureka Server工程后,启动准备测试,发现报了java.lang.NoSuchMethodError: org.springframework.boot.buil ...
- Table 组件构建过程中遇到的问题与解决思路
在 GearCase 开源项目构建 Table 组件的过程中.遇到了各式各样的问题,最后尝试了各种方法去解决这些问题. 遇到的部分问题 checkbox 的全选和半选问题 table 组件的排序请求方 ...