A - Remaining Time


Time limit : 2sec / Memory limit : 256MB

Score : 100 points

Problem Statement

Dolphin loves programming contests. Today, he will take part in a contest in AtCoder.
In this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as "21 o'clock".
The current time is A o'clock, and a contest will begin in exactly B hours. When will the contest begin? Answer in 24-hour time.

Constraints

  • 0≤A,B≤23
  • A and B are integers.

Input

The input is given from Standard Input in the following format:

A B

Output

Print the hour of the starting time of the contest in 24-hour time.


Sample Input 1

Copy
9 12

Sample Output 1

Copy
21

In this input, the current time is 9 o'clock, and 12 hours later it will be 21 o'clock in 24-hour time.


Sample Input 2

Copy
19 0

Sample Output 2

Copy
19

The contest has just started.


Sample Input 3

Copy
23 2

Sample Output 3

Copy
1

The contest will begin at 1 o'clock the next day.

题意:没啥好说的

解法:也没啥好说的

 #include<bits/stdc++.h>
using namespace std;
int n,m;
int main()
{
cin>>n>>m;
cout<<(n+m)%<<endl;
return ;
}

B - Checkpoints


Time limit : 2sec / Memory limit : 256MB

Score : 200 points

Problem Statement

There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1≤iN) is (ai,bi), and the coordinates of the checkpoint numbered j (1≤jM) is (cj,dj).
When the teacher gives a signal, each student has to go to the nearest checkpoint measured inManhattan distance
The Manhattan distance between two points (x1,y1) and (x2,y2) is |x1x2|+|y1y2|.
Here, |x| denotes the absolute value of x.
If there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index.
Which checkpoint will each student go to?

Constraints

  • 1≤N,M≤50
  • −108≤ai,bi,cj,dj≤108
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N M
a1 b1
:
aN bN
c1 d1
:
cM dM

Output

Print N lines.
The i-th line (1≤iN) should contain the index of the checkpoint for the i-th student to go.


Sample Input 1

Copy
2 2
2 0
0 0
-1 0
1 0

Sample Output 1

Copy
2
1

The Manhattan distance between the first student and each checkpoint is:

  • For checkpoint 1|2−(−1)|+|0−0|=3
  • For checkpoint 2|2−1|+|0−0|=1

The nearest checkpoint is checkpoint 2. Thus, the first line in the output should contain 2.

The Manhattan distance between the second student and each checkpoint is:

  • For checkpoint 1|0−(−1)|+|0−0|=1
  • For checkpoint 2|0−1|+|0−0|=1

When there are multiple nearest checkpoints, the student will go to the checkpoint with the smallest index. Thus, the second line in the output should contain 1.


Sample Input 2

Copy
3 4
10 10
-10 -10
3 3
1 2
2 3
3 5
3 5

Sample Output 2

Copy
3
1
2

There can be multiple checkpoints at the same coordinates.


Sample Input 3

Copy
5 5
-100000000 -100000000
-100000000 100000000
100000000 -100000000
100000000 100000000
0 0
0 0
100000000 100000000
100000000 -100000000
-100000000 100000000
-100000000 -100000000

Sample Output 3

Copy
5
4
3
2
1
题意:问最短的集合点是哪个站?如果有多个最短则输出序号最小的
解法:模拟
 #include<bits/stdc++.h>
using namespace std;
int n,m;
set<int>q;
int dis(int x1,int y1,int x2,int y2)
{
return abs(x1-x2)+abs(y1-y2);
}
int a1[],b1[],a2[],b2[];
int main()
{
cin>>n>>m;
for(int i=;i<=n;i++)
{
cin>>a1[i]>>b1[i];
}
for(int i=;i<=m;i++)
{
cin>>a2[i]>>b2[i];
}
for(int i=;i<=n;i++)
{
int pos;
int Max=(<<)-;
for(int j=;j<=m;j++)
{
int ans=dis(a1[i],b1[i],a2[j],b2[j]);
//cout<<ans<<endl;
if(ans<Max)
{
pos=j;
// cout<<pos<<endl;
Max=ans;
}
}
cout<<pos<<endl;
}
return ;
}

C - Digits in Multiplication


Time limit : 2sec / Memory limit : 256MB

Score : 300 points

Problem Statement

You are given an integer N.
For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.
For example, F(3,11)=2 since 3 has one digit and 11 has two digits.
Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such thatN=A×B.

Constraints

  • 1≤N≤1010
  • N is an integer.

Input

The input is given from Standard Input in the following format:

N

Output

Print the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such thatN=A×B.


Sample Input 1

Copy
10000

Sample Output 1

Copy
3

F(A,B) has a minimum value of 3 at (A,B)=(100,100).


Sample Input 2

Copy
1000003

Sample Output 2

Copy
7

There are two pairs (A,B) that satisfy the condition: (1,1000003) and (1000003,1). For these pairs, F(1,1000003)=F(1000003,1)=7.


Sample Input 3

Copy
9876543210

Sample Output 3

Copy
6
题意:把N分解成a*b,求出a,b中最长的长度,然后所有最长的长度中取最小的
解法:模拟
 #include<bits/stdc++.h>
using namespace std;
int n,m;
long long num;
int Max;
int Maxn=;
int main()
{
cin>>num;
for(int i=sqrt(num);i>=;i--)
{
if(num%i==)
{
int ans1=;
int ans2=;
int x=num/i;
int y=i;
while(x)
{
x/=;
ans1++;
}
while(y)
{
y/=;
ans2++;
}
Max=max(ans1,ans2);
Maxn=min(Max,Maxn);
}
}
cout<<Maxn<<endl;
return ;
}

D - Maximum Average Sets


Time limit : 2sec / Memory limit : 256MB

Score : 400 points

Problem Statement

You are given N items.
The value of the i-th item (1≤iN) is vi.
Your have to select at least A and at most B of these items.
Under this condition, find the maximum possible arithmetic mean of the values of selected items.
Additionally, find the number of ways to select items so that the mean of the values of selected items is maximized.

Constraints

  • 1≤N≤50
  • 1≤A,BN
  • 1≤vi≤1015
  • Each vi is an integer.

Input

The input is given from Standard Input in the following format:

N A B
v1
v2
...
vN

Output

Print two lines.
The first line should contain the maximum possible arithmetic mean of the values of selected items. The output should be considered correct if the absolute or relative error is at most 10−6.
The second line should contain the number of ways to select items so that the mean of the values of selected items is maximized.


Sample Input 1

Copy
5 2 2
1 2 3 4 5

Sample Output 1

Copy
4.500000
1

The mean of the values of selected items will be maximized when selecting the fourth and fifth items. Hence, the first line of the output should contain 4.5.
There is no other way to select items so that the mean of the values will be 4.5, and thus the second line of the output should contain 1.


Sample Input 2

Copy
4 2 3
10 20 10 10

Sample Output 2

Copy
15.000000
3

There can be multiple ways to select items so that the mean of the values will be maximized.


Sample Input 3

Copy
5 1 5
1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996

Sample Output 3

Copy
1000000000000000.000000
1

题意:求最大的平均值,再求出选a到选b个有几种选法可以得到最大平均值

解法:dp[i][j] 从i中选取了j个的和,sum[i][j] 从i中选取j个有多少种

 #include <bits/stdc++.h>
using namespace std;
long long dp[][],sum[][];
long long a[];
long long n,l,r;
int main()
{
for(int i=;i<=;i++)
{
sum[][i]=;
sum[i][]=;
sum[i][i]=;
}
for(int i=;i<=;i++)
{
for(int j=;j<=;j++)
{
dp[i][j]=-;
}
}
dp[][]=;
cin>>n>>l>>r;
for(int i=;i<=n;i++)
{
cin>>a[i];
}
for(int i=;i<=n;i++)
{
dp[i][]=;
for(int j=;j<=i&&j<=r;j++)
{
long long x=dp[i-][j];
long long y=dp[i-][j-]+a[i];
if(x==y)
{
dp[i][j]=x;
sum[i][j]=sum[i-][j]+sum[i-][j-];
}
else if(x>y)
{
dp[i][j]=x;
sum[i][j]=sum[i-][j];
}
else
{
dp[i][j]=y;
sum[i][j]=sum[i-][j-];
}
}
}
int pos=;
long long k=;
for(int i=l;i<=r&&i<=n;i++)
{
if(pos==)
{
pos=i;
k=sum[n][i];
}
else if(dp[n][i]*pos>dp[n][pos]*i)
{
pos=i;
k=sum[n][i];
}
else if(dp[n][i]*pos==dp[n][pos]*i)
{
k+=sum[n][i];
}
}
printf("%.6f\n",dp[n][pos]*1.0/pos*1.0);
cout<<k<<endl;
return ;
}

AtCoder Beginner Contest 057 ABCD题的更多相关文章

  1. AtCoder Beginner Contest 068 ABCD题

    A - ABCxxx Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement This contes ...

  2. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  3. AtCoder Beginner Contest 069 ABCD题

    题目链接:http://abc069.contest.atcoder.jp/assignments A - K-City Time limit : 2sec / Memory limit : 256M ...

  4. AtCoder Beginner Contest 070 ABCD题

    题目链接:http://abc070.contest.atcoder.jp/assignments A - Palindromic Number Time limit : 2sec / Memory ...

  5. AtCoder Beginner Contest 051 ABCD题

    A - Haiku Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement As a New Yea ...

  6. AtCoder Beginner Contest 052 ABCD题

    A - Two Rectangles Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement The ...

  7. AtCoder Beginner Contest 054 ABCD题

    A - One Card Poker Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Ali ...

  8. AtCoder Beginner Contest 058 ABCD题

    A - ι⊥l Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Three poles st ...

  9. AtCoder Beginner Contest 050 ABC题

    A - Addition and Subtraction Easy Time limit : 2sec / Memory limit : 256MB Score : 100 points Proble ...

随机推荐

  1. HBase数据压缩编码探索

    摘要: 本文主要介绍了hbase对数据压缩,编码的支持,以及云hbase在社区基础上对数据压缩率和访问速度上了进行的改进. 前言 你可曾遇到这种需求,只有几百qps的冷数据缓存,却因为存储水位要浪费几 ...

  2. DDD领域建模基本流程

    整理一个精简的DDD领域建模基本流程,供大家在DDD领域建模实践中进行参考. 搜集用户故事(用户的原始需求) 整理用户故事,抽出用例(用例表达了用户对系统的需求,定义了系统的边界以及系统外部角色和系统 ...

  3. Jmeter性能测试-GC相关

    1.GC相关 HotSpot虚拟机将其物理上划分为两个–新生代(young generation)和老年代(old generation).新生代(Young generation): 绝大多数最新被 ...

  4. bzoj3134: [Baltic2013]numbers

    稍微用脑子想一想,要是一个回文数,要么s[i]==s[i+1]要么s[i]==s[i+2]就可以实锤了 所以多开两维表示最近两位选的是什么数就完了 注意前导0 #include<cstdio&g ...

  5. DedeCMS模板中用彩色tag做彩色关键词

    DedeCMS模板中用彩色tag做彩色关键词,下面分享一下吧!修改方法: 1.在/include/common.func.php 中加入如下函数: function getTagStyle() { $ ...

  6. springboot使用thymeleaf 解析异常

    在使用springboot的过程中,如果使用thymeleaf作为模板文件,则要求HTML格式必须为严格的html5格式,必须有结束标签,否则会报错!解决办法如下: 1.你可以使用严格的标签,也就是每 ...

  7. hdu 2544 最短路 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544 题目意思:给出 n 个路口和 m 条路,每一条路需要 c 分钟走过.问从路口 1 到路口 n 需 ...

  8. UVA-11054(扫描法)

    题意: n个等距村庄,每个村庄要么买酒要么卖酒,把k个单位的酒运到相邻村庄去需要k个单位的劳动力,问最少需要多少劳动力才能满足所有的村庄的要求; 思路: 上次做了一个环的,这个是直线的,就是一个大水题 ...

  9. Gym - 100342J:Triatrip(Bitset加速求三元环的数量)

    题意:求有向图里面有多少个三元环. 思路:枚举起点A,遍历A可以到的B,然后求C的数量,C的数量位B可以到是地方X集合,和可以到A的地方Y集合的交集(X&Y). B点可以枚举,也可以遍历.(两 ...

  10. BZOJ_1812_[Ioi2005]riv_树形DP

    BZOJ_1812_[Ioi2005]riv_树形DP Description 几乎整个Byteland王国都被森林和河流所覆盖.小点的河汇聚到一起,形成了稍大点的河.就这样,所有的河水都汇聚并流进了 ...