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 from0through9.
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 ;
}
AtCoder Beginner Contest 084(AB)的更多相关文章
- AtCoder Beginner Contest 083 (AB)
A - Libra 题目链接:https://abc083.contest.atcoder.jp/tasks/abc083_a Time limit : 2sec / Memory limit : 2 ...
- AtCoder Beginner Contest 254(D-E)
Tasks - AtCoder Beginner Contest 254 D - Together Square 题意: 给定一个N,找出所有不超过N的 ( i , j ),使得( i * j )是一 ...
- AtCoder Beginner Contest 086 (ABCD)
A - Product 题目链接:https://abc086.contest.atcoder.jp/tasks/abc086_a Time limit : 2sec / Memory limit : ...
- AtCoder Beginner Contest 085(ABCD)
A - Already 2018 题目链接:https://abc085.contest.atcoder.jp/tasks/abc085_a Time limit : 2sec / Memory li ...
- AtCoder Beginner Contest 264(D-E)
D - "redocta".swap(i,i+1) 题意: 给一个字符串,每次交换相邻两个字符,问最少多少次变成"atcoder" 题解: 从左到右依次模拟 # ...
- Atcoder Beginner Contest 155E(DP)
#definde HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ]; int main(){ ios: ...
- Atcoder Beginner Contest 156E(隔板法,组合数学)
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ; ; long long fac[N] ...
- Atcoder Beginner Contest 121D(异或公式)
#include<bits/stdc++.h>using namespace std;int main(){ long long a,b; cin>>a>&g ...
- Atcoder Beginner Contest 155D(二分,尺取法,细节模拟)
二分,尺取法,细节模拟,尤其是要注意a[i]被计算到和a[i]成对的a[j]里时 #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> ...
随机推荐
- HttpUrlConneciton上传JSON数据
try { //创建连接 URL url = new URL(url); HttpURLConnection connection = (HttpURLConnection) url.openConn ...
- Python递归优化方法
递归栈溢出 Python的递归调用栈的深度有限制,默认深度为998,可以通过sys.getrecursionlimit()查看. 针对递归栈溢出,我们可以将默认深度设置为大一些,这样不会报错,但是再大 ...
- what's the python之可迭代对象、迭代器与生成器(附面试题)
可迭代对象 字符串.列表.元祖.集合.字典都是可迭代的,数字是不可迭代的.(可以用for循环遍历取出内部元素的就是可迭代的) 如何查看一个变量是否为可迭代: from collections impo ...
- Element-table-formatter格式化数据
1.formatter 用来格式化内容 对table的值进行处理.Function(row, column, cellValue, index){} 使用formatter需要注意以下几点: ...
- java -jstack
一.介绍 jstack是java虚拟机自带的一种堆栈跟踪工具.jstack用于打印出给定的java进程ID或core file或远程调试服务的Java堆栈信息,如果是在64位机器上,需要指定选项&qu ...
- inner join, left join, right join 和 full join
inner join:理解为“有效连接”,两张表中都有的数据才会显示left join:理解为“有左显示”,比如on a.field=b.field,则显示a表中存在的全部数据及a.b中都有的数据,a ...
- k8s pv 的三种挂载模式
ReadWriteOnce:可读可写,只能被一个Node节点挂载 ReadWriteMany:可读可写,可以被多个Node节点挂载 ReadOnlyMany:只读,能被多个Node节点挂载
- openvpn-客户端配置文件
############################################## # 针对多个客户端的OpenVPN 2.0 的客户端配置文件示例 # # 该配置文件可以被多个客户端使用, ...
- golang 获取get参数
package main import ( "log" "net/http" ) func main() { http.HandleFunc("/&q ...
- ODBC的JAR包和PLSQL
eclipse编辑器,写java 下载ODBC的JAR包 配置一下用户名和密码 java连接上数据库后 不是直接操作数据库 在代码里面有SQL语句 代码执行的时候遇到这些语句就可以操作数据库 平时操 ...