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:

  1. A B

Output

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


Sample Input 1

Copy
  1. 9 12

Sample Output 1

Copy
  1. 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
  1. 19 0

Sample Output 2

Copy
  1. 19

The contest has just started.


Sample Input 3

Copy
  1. 23 2

Sample Output 3

Copy
  1. 1

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

题意:没啥好说的

解法:也没啥好说的

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int n,m;
  4. int main()
  5. {
  6. cin>>n>>m;
  7. cout<<(n+m)%<<endl;
  8. return ;
  9. }

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:

  1. N M
  2. a1 b1
  3. :
  4. aN bN
  5. c1 d1
  6. :
  7. 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
  1. 2 2
  2. 2 0
  3. 0 0
  4. -1 0
  5. 1 0

Sample Output 1

Copy
  1. 2
  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
  1. 3 4
  2. 10 10
  3. -10 -10
  4. 3 3
  5. 1 2
  6. 2 3
  7. 3 5
  8. 3 5

Sample Output 2

Copy
  1. 3
  2. 1
  3. 2

There can be multiple checkpoints at the same coordinates.


Sample Input 3

Copy
  1. 5 5
  2. -100000000 -100000000
  3. -100000000 100000000
  4. 100000000 -100000000
  5. 100000000 100000000
  6. 0 0
  7. 0 0
  8. 100000000 100000000
  9. 100000000 -100000000
  10. -100000000 100000000
  11. -100000000 -100000000

Sample Output 3

Copy
  1. 5
  2. 4
  3. 3
  4. 2
  5. 1
    题意:问最短的集合点是哪个站?如果有多个最短则输出序号最小的
    解法:模拟
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int n,m;
  4. set<int>q;
  5. int dis(int x1,int y1,int x2,int y2)
  6. {
  7. return abs(x1-x2)+abs(y1-y2);
  8. }
  9. int a1[],b1[],a2[],b2[];
  10. int main()
  11. {
  12. cin>>n>>m;
  13. for(int i=;i<=n;i++)
  14. {
  15. cin>>a1[i]>>b1[i];
  16. }
  17. for(int i=;i<=m;i++)
  18. {
  19. cin>>a2[i]>>b2[i];
  20. }
  21. for(int i=;i<=n;i++)
  22. {
  23. int pos;
  24. int Max=(<<)-;
  25. for(int j=;j<=m;j++)
  26. {
  27. int ans=dis(a1[i],b1[i],a2[j],b2[j]);
  28. //cout<<ans<<endl;
  29. if(ans<Max)
  30. {
  31. pos=j;
  32. // cout<<pos<<endl;
  33. Max=ans;
  34. }
  35. }
  36. cout<<pos<<endl;
  37. }
  38. return ;
  39. }

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:

  1. 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
  1. 10000

Sample Output 1

Copy
  1. 3

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


Sample Input 2

Copy
  1. 1000003

Sample Output 2

Copy
  1. 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
  1. 9876543210

Sample Output 3

Copy
  1. 6
    题意:把N分解成a*b,求出ab中最长的长度,然后所有最长的长度中取最小的
    解法:模拟
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int n,m;
  4. long long num;
  5. int Max;
  6. int Maxn=;
  7. int main()
  8. {
  9. cin>>num;
  10. for(int i=sqrt(num);i>=;i--)
  11. {
  12. if(num%i==)
  13. {
  14. int ans1=;
  15. int ans2=;
  16. int x=num/i;
  17. int y=i;
  18. while(x)
  19. {
  20. x/=;
  21. ans1++;
  22. }
  23. while(y)
  24. {
  25. y/=;
  26. ans2++;
  27. }
  28. Max=max(ans1,ans2);
  29. Maxn=min(Max,Maxn);
  30. }
  31. }
  32. cout<<Maxn<<endl;
  33. return ;
  34. }

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:

  1. N A B
  2. v1
  3. v2
  4. ...
  5. 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
  1. 5 2 2
  2. 1 2 3 4 5

Sample Output 1

Copy
  1. 4.500000
  2. 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
  1. 4 2 3
  2. 10 20 10 10

Sample Output 2

Copy
  1. 15.000000
  2. 3

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


Sample Input 3

Copy
  1. 5 1 5
  2. 1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996

Sample Output 3

Copy
  1. 1000000000000000.000000
  2. 1

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

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

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. long long dp[][],sum[][];
  4. long long a[];
  5. long long n,l,r;
  6. int main()
  7. {
  8. for(int i=;i<=;i++)
  9. {
  10. sum[][i]=;
  11. sum[i][]=;
  12. sum[i][i]=;
  13. }
  14. for(int i=;i<=;i++)
  15. {
  16. for(int j=;j<=;j++)
  17. {
  18. dp[i][j]=-;
  19. }
  20. }
  21. dp[][]=;
  22. cin>>n>>l>>r;
  23. for(int i=;i<=n;i++)
  24. {
  25. cin>>a[i];
  26. }
  27. for(int i=;i<=n;i++)
  28. {
  29. dp[i][]=;
  30. for(int j=;j<=i&&j<=r;j++)
  31. {
  32. long long x=dp[i-][j];
  33. long long y=dp[i-][j-]+a[i];
  34. if(x==y)
  35. {
  36. dp[i][j]=x;
  37. sum[i][j]=sum[i-][j]+sum[i-][j-];
  38. }
  39. else if(x>y)
  40. {
  41. dp[i][j]=x;
  42. sum[i][j]=sum[i-][j];
  43. }
  44. else
  45. {
  46. dp[i][j]=y;
  47. sum[i][j]=sum[i-][j-];
  48. }
  49. }
  50. }
  51. int pos=;
  52. long long k=;
  53. for(int i=l;i<=r&&i<=n;i++)
  54. {
  55. if(pos==)
  56. {
  57. pos=i;
  58. k=sum[n][i];
  59. }
  60. else if(dp[n][i]*pos>dp[n][pos]*i)
  61. {
  62. pos=i;
  63. k=sum[n][i];
  64. }
  65. else if(dp[n][i]*pos==dp[n][pos]*i)
  66. {
  67. k+=sum[n][i];
  68. }
  69. }
  70. printf("%.6f\n",dp[n][pos]*1.0/pos*1.0);
  71. cout<<k<<endl;
  72. return ;
  73. }

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. PandoraBox 支持3G无线上网卡(电信卡3G卡)(三)

    笔者采用的是华为EC122无线上网卡 一:编辑/etc/modules.d/60-usb-serial usbserial vendor=0x12d1   product=0x1505 二:编辑/et ...

  2. Apache Qpid 高可用集群

    一.RHCS RHCS是Red Hat Cluster Suite(红帽子集群套件)的缩写.RHCS是一个功能完备的集群应用解决方案,它从应用的前端访问到后端的数据存储都提供了一个行之有效的集群架构实 ...

  3. rtsp 播放器

    http://blog.csdn.net/niu_gao/article/details/7753672 /********************************************** ...

  4. 查询历史使用过的命令并使用(history)

    一.什么是history 在bash功能中.它能记忆使用过的命令,这个功能最大的优点就是能够查询以前做过的举动.从而能够知道你的执行步骤.那么就能够追踪你曾下达过的命令.以作为除错的工具. 二.His ...

  5. ios如何获取手机的网络状态和运营商名称

    本文转载至 http://blog.csdn.net/justinjing0612/article/details/38313747 以前获取手机的网络状态和运营商名称都是似有API, 现在我们可以大 ...

  6. sessionFactory的创建和四种查询方式

    1,关于sessionFactory的创建 5.0版本之前,下面这种方式在5.0及之后,可能会出问题,建议修改为5.0之后的方式 // 实例化Configuration Configuration c ...

  7. html5--6-59 其他常用CSS属性

    html5--6-59 其他常用CSS属性 实例 学习要点 了解opacity属性:透明度设定 了解cursor属性:自定义鼠标样式 了解CSS新单位rem和em的区别 了解轮廓outline的设置 ...

  8. (转)Vim自动补全神器:YouCompleteMe

    原文出处:http://blog.jobbole.com/58978/ 第一次听说这个插件还是在偶然的情况下看到别人的博客,听说了这个插件的大名.本来打算在实训期间来完成安装的,无奈网实在不给力,也就 ...

  9. object_funs.py

    #__init__ 构造方法,双下划线 #__del__ 析构方法,在对象就要被垃圾回收前调用.但发生调用 #的具体时间是不可知的.所以建议尽量避免使用__del__ print('-------ex ...

  10. 后缀自动机SAM BZOJ 2806

    终于遇到了一道后缀数组不能过 一定要学SAM的题... (看了半个下午+半个上午) 现在总结一下(是给我自己总结..所以只总结了我觉得重要的 .. 看不太懂的话可以To   http://blog.c ...