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:
MOutput
If we have?x?hours until New Year at?M?o'clock on?30th, December, print?x.
Sample Input 1
Copy 21Sample Output 1
Copy 27We have?27?hours until New Year at?21?o'clock on?30th, December.
Sample Input 2
Copy 12Sample 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 CodeB - 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 SOutput
Print?Yes?if?S?follows the postal code format in AtCoder Kingdom; print?No?otherwise.
Sample Input 1
Copy 3 4 269-6650Sample Output 1
Copy YesThe?(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 NoS?contains unnecessary?-s other than the?(A+1)-th character, so it does not follow the format.
Sample Input 3
Copy 1 2 7444Sample 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)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PostgreSQL 9.6 keepa
- 下一篇: 网络编程---黏包