L1-018 大笨钟
Statement
Metadata
- 作者: 陈越
 - 单位: 浙江大学
 - 代码长度限制: 16 KB
 - 时间限制: 400 ms
 - 内存限制: 64 MB
 
微博上有个自称“大笨钟V”的家伙,每天敲钟催促码农们爱惜身体早点睡觉。不过由于笨钟自己作息也不是很规律,所以敲钟并不定时。一般敲钟的点数是根据敲钟时间而定的,如果正好在某个整点敲,那么“当”数就等于那个整点数;如果过了整点,就敲下一个整点数。另外,虽然一天有24小时,钟却是只在后半天敲1~12下。例如在23:00敲钟,就是“当当当当当当当当当当当”,而到了23:01就会是“当当当当当当当当当当当当”。在午夜00:00到中午12:00期间(端点时间包括在内),笨钟是不敲的。
下面就请你写个程序,根据当前时间替大笨钟敲钟。
输入格式
输入第一行按照hh:mm的格式给出当前时间。其中hh是小时,在00到23之间;mm是分钟,在00到59之间。
输出格式
根据当前时间替大笨钟敲钟,即在一行中输出相应数量个Dang。如果不是敲钟期,则输出:
其中hh:mm是输入的时间。
输入样例1
输出样例1
输入样例2
输出样例2
Solution
#include <ctype.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;
const double PI = 3.14159265358979323846264338327;
const double E = 2.718281828459;
const double eps = 1e-6;
const int MAXN = 0x3f3f3f3f;
const int MINN = 0xc0c0c0c0;
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;
int main() {
    int a, b;
    scanf("%d:%d", &a, &b);
    if (a < 12 || (a == 12 && b == 0))
        printf("Only %02d:%02d.  Too early to Dang.\n", a, b);
    else {
        a -= 12;
        for (int i = 0; i < a; i++) printf("Dang");
        if (b)
            printf("Dang");
        cout << endl;
    }
}
  Last update: May 4, 2022