1 条题解

  • 0
    @ 2025-8-28 11:41:40

    本题考察时、分、秒的转换。 数字可能稍微有点大,注意即可(不会爆int)。

    #include <bits/stdc++.h>
    using namespace std;
    int h, m, s, k;
    int main(void) {
    	cin >> h >> m >> s >> k;
    	int total = h * 3600 + m * 60 + s;
    	int end_time = (total + k) % (24 * 3600);
    	int new_h = end_time / 3600;
    	int last = end_time % 3600;
    	int new_m = last / 60;
    	int new_s = last % 60;
    	cout << new_h << ' ' << new_m << ' ' << new_s;
    	return 0;
    }

    信息

    ID
    39
    时间
    1000ms
    内存
    256MiB
    难度
    1
    标签
    递交数
    4
    已通过
    4
    上传者