蓝桥杯时间显示

题目链接:https://www.lanqiao.cn/problems/1452/learning/;

看题目数据10^18是很吓人的,我以为得用高精度..........;

不!实则不然!long long 就可以过

然后这个题就变成模拟了:

#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long day = 24*60*60*1000;
  long long time;
   ios::sync_with_stdio(false);
  cin >> time;
  time = time%day;
  int t1 = time/(60*60*1000);
  time = time%(60*60*1000);
  int t2 = time/(60*1000);
  time = time%(60*1000);
  int t3 = time/(1000);
  printf("%02d:%02d:%02d\n",t1,t2,t3);
  return 0;
}

  

posted @ 2022-03-29 17:23  江上舟摇  阅读(76)  评论(0编辑  收藏  举报