AtCoder Beginner Contest 084(AB)
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
21
Sample Output 1
27
We have 27 hours until New Year at 21 o'clock on 30th, December.
Sample Input 2
12
Sample Output 2
36
#include <iostream>
using namespace std;
int main()
{
int n;
while(cin>>n){
cout<<-n+<<endl;
}
return ;
}
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 from0
through9
.
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
3 4
269-6650
Sample Output 1
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
1 1
---
Sample Output 2
No
S contains unnecessary -
s other than the (A+1)-th character, so it does not follow the format.
Sample Input 3
1 2
7444
Sample Output 3
No
#include <iostream>
using namespace std;
int main()
{
int a,b;
while(cin>>a>>b){
string s;
cin>>s;
int l=s.length();
int flag=;
for(int i=;i<l;i++){
if(i==a&&s[i]!='-'){
flag=;
break;
}
if(i!=a&&!(s[i]<=''&&s[i]>='')){
flag=;
break;
}
}
if(flag) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return ;
}
最新文章
- React 入门教程
- 基于fis3的组件可视化道路
- spring源码:IOC(li)
- 【WPF系列】基础 PasswordBox
- NSOperationQueue与GCD的使用原则和场景
- Integer &; int &; == &; equals
- Adroid 总结--android ListView美化,个性化更改的属性
- 鸟哥的linux私房菜学习
- Context Menu on DataGrid
- struts2 jsp表单提交后保留表单中输入框中的值 下拉框select与input
- C#微信公众号开发 -- (二)验证成为开发者
- Swift - 启动时的向导页(新手引导)的制作
- js添加多个样式属性cssText
- 一个操作cvs格式的c++类
- RedHat Linux关闭防火墙的命令
- Fox And Dinner CodeForces - 510E (最大流)
- Linux图形操作与命令行
- php -- 4种嵌入标记
- smarty模板开发基础总结
- 在Unity中查找缺失的引用
热门文章
- AdvStringGrid常用操作
- 006-docker-安装-nginx
- error: Microsoft Visual C++ 14.0 is required(line_profiler模块安装失败的解决办法)
- 前端框架之Vue(6)-列表渲染
- react 脚手架--create-react-app
- 2019.03.25 Ajax三级联动
- python 微信机器人,微信自动回复
- InstallShield12的安装破解方法
- python 格式化字符串";%s";%
- cocos2dx 3.x(打开网页webView)