A - New Year

题目链接:https://abc084.contest.atcoder.jp/tasks/abc084_a


Time limit : 2sec / Memory limit : 256MB

Score : 100 points

Problem Statement

How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?

Constraints

  • 1≤M≤23
  • M is an integer.

Input

Input is given from Standard Input in the following format:

M

Output

If we have x hours until New Year at M o'clock on 30th, December, print x.


Sample Input 1

Copy
21

Sample Output 1

Copy
27

We have 27 hours until New Year at 21 o'clock on 30th, December.


Sample Input 2

Copy
12

Sample Output 2

Copy
36

 1 #include <iostream>
 2 using namespace std;
 3 int main()
 4 {
 5     int n;
 6     while(cin>>n){
 7         cout<<24-n+24<<endl;
 8     }
 9     return 0;
10 }

View Code

B - Postal Code

题目链接:https://abc084.contest.atcoder.jp/tasks/abc084_b


Time limit : 2sec / Memory limit : 256MB

Score : 200 points

Problem Statement

The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9.

You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.

Constraints

  • 1≤A,B≤5
  • |S|=A+B+1
  • S consists of - and digits from 0 through 9.

Input

Input is given from Standard Input in the following format:

A B
S

Output

Print Yes if S follows the postal code format in AtCoder Kingdom; print No otherwise.


Sample Input 1

Copy
3 4
269-6650

Sample Output 1

Copy
Yes

The (A+1)-th character of S is -, and the other characters are digits from 0 through 9, so it follows the format.


Sample Input 2

Copy
1 1
---

Sample Output 2

Copy
No

S contains unnecessary -s other than the (A+1)-th character, so it does not follow the format.


Sample Input 3

Copy
1 2
7444

Sample Output 3

Copy
No


 1 #include <iostream>
 2 using namespace std;
 3 int main()
 4 {
 5     int a,b;
 6     while(cin>>a>>b){
 7         string s;
 8         cin>>s;
 9         int l=s.length();
10         int flag=1;
11         for(int i=0;i<l;i++){
12             if(i==a&&s[i]!='-'){
13                 flag=0;
14                 break;
15             }
16             if(i!=a&&!(s[i]<='9'&&s[i]>='0')){
17                 flag=0;
18                 break;
19             }
20         }
21         if(flag) cout<<"Yes"<<endl;
22         else cout<<"No"<<endl;
23     }
24     return 0;
25 }

View Code

转载于:https://www.cnblogs.com/shixinzei/p/8342893.html

AtCoder Beginner Contest 084(AB)相关推荐

  1. AtCoder Beginner Contest 266(C- G)「判凸包」「dp」「期望」「基环树」「组合数」

    abc好好好. C - Convex Quadrilateral (atcoder.jp) 思路: 判凸包,向量叉积×=|a|*|b|*sin.叉积<0即角>180°. (可以勉勉强强算我 ...

  2. AtCoder Beginner Contest 295(DEG)

    D - Three Days Ago (atcoder.jp) (1)题目大意 (2)解题思路 考虑使用前缀和的思路,把每一个位置0-9的数量的奇偶表示出来,用一个map或者hash维护一下即可,每一 ...

  3. AtCoder Beginner Contest 262(ABC262)A-Ex 题解

    A - World Cup 我懒得分类讨论,直接枚举. #include<bits/stdc++.h> #define Max(a,b) ((a<b)&&(a=b)) ...

  4. AtCoder Beginner Contest 198 (A ~ F)题解

    目录 A. Div B. Palindrome with leading zeros C. Compass Walking D. Send More Money E. Unique Color F. ...

  5. AtCoder Beginner Contest 203(Sponsored by Panasonic)题解

    文章目录 A - Chinchirorin B - AtCoder Condominium C - Friends and Travel costs D - Pond E - White Pawn F ...

  6. AtCoder Beginner Contest 203(Sponsored by Panasonic)D.Pond

    题目链接 Problem Statement The land of a park AtCoder is an N×NN×NN×N grid with east-west rows and north ...

  7. 数学--数论-- AtCoder Beginner Contest 151(组合数+数学推导)好题(๑•̀ㅂ•́)و✧

    思路统计最大值出现的次数,和最小值出现的次数.虽然是每次都是MAX-MIN,我们先求MAX的和,然后再求MIN的和,做差. 这次代码写的真的很漂亮 题目地址: #include <bits/st ...

  8. AtCoder Beginner Contest 214(补题)

    C - Distribution 题意: 每个人都会在ttt这个时间得到一个宝石,每个人都会处理宝石sss时间,所以第iii个人会在tit_iti​时间得到宝石,并在ti+siti+siti+si时间 ...

  9. AtCoder Beginner Contest 203(Sponsored by Panasonic) D.Pond(二分+二维前缀和)

    link 思路: 先来想想暴力的写法: n2n^{2}n2枚举左上角的顶点,k2k^{2}k2求最小值. 考虑优化: 1.1.1.答案有单调性,可以二分答案,省去枚举左上角顶点的复杂度. 2.2.2. ...

最新文章

  1. 内核层CS段描述符信息
  2. 简单安装Harbor私有镜像仓库
  3. c 添加mysql表单的一行数据类型_MySQL数据库基础
  4. 一张图图片分块html,css img图片是内联还是块?
  5. sql判断时间差值_Oracle判断某人员在某地是否有超过指定时间的停留
  6. ERROR: “System.Web.Mvc.Controller.File(string, string, string)”是一个“方法”
  7. Altium Designer安装教程,适合小白的一键安装,简单明了,傻瓜式安装
  8. 遗传算法求解函数最大值的python实现
  9. select_related和prefetch_related的区别是什么?
  10. android实现第三方QQ登录
  11. 拓嘉辰丰:影响拼多多直通车推广效果的因素有哪些?
  12. java左手画圆右手画方_左手画圆、右手画方,双手齐用同时养护、开发你的左右大脑!...
  13. Markdown语法笔记
  14. python阶梯图_不会你还不懂怎么用Python制图吧?师兄教你如何学会绘制漂亮的阶梯图...
  15. 野蛮成长的健身行业何时能迎来春天?
  16. java内存(java内存溢出的几种原因和解决办法)
  17. slow log mysql_MySQL Slow Log慢日志分析(一)
  18. 频率分布直方图和累积频率分布图
  19. 卖猪肉比程序员赚得多多了?
  20. python PIL读取图像转换为灰度图及二值图像

热门文章

  1. Something about Giraffe (II)
  2. android getinstance 方法,Android中的'new Fragment()'和'Fragment.getInstance()'有什么区别?...
  3. matlab光学毕业论文,光学信息处理实验的Matlab仿真.doc
  4. 商品pid是什么意思_0基础搞懂自动驾驶传统算法与深度学习的鸿沟-PID控制算法与MLP优化方法...
  5. Linux禁止非WHEEL用户使用SU命令
  6. MATLAB的size、length函数
  7. 联想服务器支持esxi版本,联想中国(Lenovo China)_服务频道_服务政策
  8. conda 安装mysql_centos7安装mysql
  9. java数组使用实验报告_JAVA数组与类的定义-java实验报告
  10. js判断移动端,pc端,安卓,苹果浏览器的方法