AtCoder Beginner Contest 058 ABCD题
A - ι⊥l
Time limit : 2sec / Memory limit : 256MB
Score : 100 points
Problem Statement
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles beautiful if the tops of the poles lie on the same line, that is, b−a=c−b.
Determine whether the arrangement of the poles is beautiful.
Constraints
- 1≤a,b,c≤100
- a, b and c are integers.
Input
Input is given from Standard Input in the following format:
a b c
Output
Print YES
if the arrangement of the poles is beautiful; print NO
otherwise.
Sample Input 1
2 4 6
Sample Output 1
YES
Since 4−2=6−4, this arrangement of poles is beautiful.
Sample Input 2
2 5 6
Sample Output 2
NO
Since 5−2≠6−5, this arrangement of poles is not beautiful.
Sample Input 3
3 2 1
Sample Output 3
YES
Since 1−2=2−3, this arrangement of poles is beautiful.
题意:额。。
解法:额
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; ll an[],am[];
int main()
{
int a,b,c;
cin>>a>>b>>c;
if(b-a==c-b)
{
cout<<"YES"<<endl;
}
else
{
cout<<"NO"<<endl;
}
return ;
}
B - ∵∴∵
Time limit : 2sec / Memory limit : 256MB
Score : 200 points
Problem Statement
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password.
Constraints
- O and E consists of lowercase English letters (
a
-z
). - 1≤|O|,|E|≤50
- |O|−|E| is either 0 or 1.
Input
Input is given from Standard Input in the following format:
O
E
Output
Print the original password.
Sample Input 1
xyz
abc
Sample Output 1
xaybzc
The original password is xaybzc
. Extracting the characters at the odd-numbered positions results in xyz
, and extracting the characters at the even-numbered positions results in abc
.
Sample Input 2
atcoderbeginnercontest
atcoderregularcontest
Sample Output 2
aattccooddeerrbreeggiunlnaerrccoonntteesstt
题意:额
解法:额
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s1,s2,s3;
int main()
{
int num1=;
int num2=;
cin>>s1;
cin>>s2;
for(int i=;i<s1.size()+s2.size();i++)
{
if(i%)
{
cout<<s2[num1++];
}
else
{
cout<<s1[num2++];
}
}
cout<<endl;
return ;
}
C - 怪文書 / Dubious Document
Time limit : 2sec / Memory limit : 256MB
Score : 300 points
Problem Statement
Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string.
He will receive a headline which contains one of the strings S1,…,Sn tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains.
Find the longest string that can be created regardless of which string among S1,…,Sn the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.
Constraints
- 1≤n≤50
- 1≤|Si|≤50 for every i=1,…,n.
- Si consists of lowercase English letters (
a
-z
) for every i=1,…,n.
Input
Input is given from Standard Input in the following format:
n
S1
…
Sn
Output
Print the lexicographically smallest string among the longest strings that satisfy the condition. If the answer is an empty string, print an empty line.
Sample Input 1
3
cbaa
daacc
acacac
Sample Output 1
aac
The strings that can be created from each of cbaa
, daacc
and acacac
, are aa
, aac
, aca
, caa
and so forth. Among them, aac
, aca
andcaa
are the longest, and the lexicographically smallest of these three is aac
.
Sample Input 2
3
a
aa
b
Sample Output 2
The answer is an empty string.
题意:选择字符串公共的字母,哪个字母出现次数最少就加进去,比如a在第一个字符串只出现了次,于是有aa
解法:模拟
#include <bits/stdc++.h> using namespace std;
string s[];
int n;
map<char,int>q;
string s1;
int main()
{
cin>>n;
for(int i=; i<n; i++)
{
cin>>s[i];
}
for(char i='a'; i<='z'; i++)
{
int flag=;
for(int j=; j<n; j++)
{
if(s[j].find(i)==-)
{
flag=;
}
}
if(flag==)
{
int minn=;
// cout<<i<<endl;
for(int j=; j<n; j++)
{
int cnt=;
for(int z=;z<s[j].size();z++)
{
if(s[j][z]==i)
{
cnt++;
}
}
minn=min(minn,cnt);
}
for(int j=;j<minn;j++)
{
s1+=i;
}
}
}
cout<<s1<<endl;
return ;
}
D - 井井井 / ###
Time limit : 2sec / Memory limit : 256MB
Score : 500 points
Problem Statement
On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y=yi. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x=xi.
For every rectangle that is formed by these lines, find its area, and print the total area modulo 109+7.
That is, for every quadruple (i,j,k,l) satisfying 1≤i<j≤n and 1≤k<l≤m, find the area of the rectangle formed by the lines x=xi, x=xj, y=yk and y=yl, and print the sum of these areas modulo 109+7.
Constraints
- 2≤n,m≤105
- −109≤x1<…<xn≤109
- −109≤y1<…<ym≤109
- xi and yi are integers.
Input
Input is given from Standard Input in the following format:
n m
x1 x2 … xn
y1 y2 … ym
Output
Print the total area of the rectangles, modulo 109+7.
Sample Input 1
3 3
1 3 4
1 3 6
Sample Output 1
60
The following figure illustrates this input:
The total area of the nine rectangles A, B, ..., I shown in the following figure, is 60.
Sample Input 2
6 5
-790013317 -192321079 95834122 418379342 586260100 802780784
-253230108 193944314 363756450 712662868 735867677
Sample Output 2
835067060
题意:把这里面所有的正方形面积都加一次
解法: ∑∑(xi-xj)(yi-yj)1<=i<=n 1<=j<=m
把上面分开有:
于是...就出来了
#include<bits/stdc++.h>
//std::ios::sync_with_stdio(false);
using namespace std;
typedef long long ll;
ll n,m;
ll sx;
ll sy;
ll mod=1e9+;
ll x[],y[];
int main()
{
cin>>n>>m;
for(ll i=;i<=n;i++)
{
cin>>x[i];
}
for(ll i=;i<=m;i++)
{
cin>>y[i];
}
for(ll i=;i<=n;i++)
{
sx+=((i-)*x[i]-(n-i)*x[i])%mod;
sx%=mod;
}
for(ll i=;i<=m;i++)
{
sy+=((i-)*y[i]-(m-i)*y[i])%mod;
sy%=mod;
}
cout<<sx%mod*sy%mod<<endl;
return ;
}
AtCoder Beginner Contest 058 ABCD题的更多相关文章
- AtCoder Beginner Contest 068 ABCD题
A - ABCxxx Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement This contes ...
- AtCoder Beginner Contest 053 ABCD题
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...
- AtCoder Beginner Contest 069 ABCD题
题目链接:http://abc069.contest.atcoder.jp/assignments A - K-City Time limit : 2sec / Memory limit : 256M ...
- AtCoder Beginner Contest 070 ABCD题
题目链接:http://abc070.contest.atcoder.jp/assignments A - Palindromic Number Time limit : 2sec / Memory ...
- AtCoder Beginner Contest 057 ABCD题
A - Remaining Time Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Dol ...
- AtCoder Beginner Contest 051 ABCD题
A - Haiku Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement As a New Yea ...
- AtCoder Beginner Contest 052 ABCD题
A - Two Rectangles Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement The ...
- AtCoder Beginner Contest 054 ABCD题
A - One Card Poker Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Ali ...
- AtCoder Beginner Contest 050 ABC题
A - Addition and Subtraction Easy Time limit : 2sec / Memory limit : 256MB Score : 100 points Proble ...
随机推荐
- MapReduce简述、工作流程及新旧API对照
什么是MapReduce? 你想数出一摞牌中有多少张黑桃.直观方式是一张一张检查而且数出有多少张是黑桃. MapReduce方法则是: 1. 给在座的全部玩家中分配这摞牌. 2. 让每一个玩家数自己手 ...
- Codeforces Round #422 (Div. 2) D. My pretty girl Noora 数学
D. My pretty girl Noora In Pavlopolis University where Noora studies it was decided to hold beau ...
- MapReduce算法形式五:TOP—N
案例五:TOP—N 这个问题比较常见,一般都用于求前几个或者后几个的问题,shuffle有一个默认的排序是正序的,但如果需要逆序的并且暂时还不知道如何重写shuffle的排序规则的时候就用以下方法就行 ...
- Immutable学习及 React 中的实践
为什么用immutable.js呢.有了immutable.js可以大大提升react的性能. JavaScript 中的对象一般是可变的(Mutable),因为使用了引用赋值,新的对象简单的引用了原 ...
- php composer 相关及版本约束等小技巧
对于现代语言而言,包管理器基本上是标配.Java有Maven,Python有pip,Ruby有gem,Nodejs有npm.PHP的则是PEAR,不过PEAR坑不少: 依赖处理容易出问题 配置非常复杂 ...
- node js 安装时选择勾上path
勾上path则会自动配置环境变量,否则必须手动去添加nodejs的环境变量.
- HTTP服务器用什么组件或者方式比较好
我目前用Indy的HttpServer组件来编写,但遇到一个暂时没有办法解决的问题,就是上传文件到这个HTTPServer,如果文件名包含中文,则会出现乱码.网上查了一下,这是个indy的遗留问题,据 ...
- p1697食物链
动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形.A吃B, B吃C,C吃A.现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种.有人用两种说法 ...
- Shell 脚本实现 Linux 系统监控
一.实验介绍 1.1 实验内容 本课程实现 shell 脚本监控系统的各项参数,并可以将脚本加入系统环境中,可以直接在终端里执行.还添加了几个参数,一个脚本可以执行不同的操作. 1.2 知识点 本实验 ...
- MYSQL进阶学习笔记四:MySQL存储过程之定义条件,处理过程及存储过程的管理!(视频序号:进阶_11,12)
知识点五:MySQL存储过程之定义条件和处理过程及存储过程的管理(11,12) 定义条件和处理: 条件的定义和处理可以用来定义在处理过程中遇到的问题时相应的处理步骤. DECLARE CONTINUE ...