4 solutions

  • 0
    @ 2023-2-26 21:09:17
    #include <iostream>
    #include <cstdio>
    using namespace std;
    
    typedef long long LL;
    LL t;
    int hour,mint,sec;
    
    int main(){
    	
    	cin>>t;
    	t /= 1000;
    	LL oneday = 60*60*24;
    	t %= oneday;
    	hour = t/(60*60);
    	mint = (t/60)%(60);
    	sec = (t-60*60*hour-60*mint);
    	printf("%02d:%02d:%02d",hour,mint,sec) ;
    	
    	
    	
    	
    	return 0;
    }
    
    • 0
      @ 2022-1-23 22:38:15

      打卡

      #include <bits/stdc++.h>
      using namespace std;
      #define ll unsigned long long
      int main(){
      	ll n;
      	cin>>n;
      	n/=1000;
      	ll k=n/3600; 
      	ll H=k%24;
      	n-=k*3600;
      	ll m=n/60;
      	n-=m*60;
      	if(H<=9) cout<<"0"<<H<<":";
      	else cout<<H<<":";
      	if(m<=9) cout<<"0"<<m<<":";
      	else cout<<m<<":";
      	if(n<=9) cout<<"0"<<n;
      	else cout<<n;
      	return 0;
      } 
      
      • 0
        @ 2022-1-23 21:01:37
        #include<bits/stdc++.h>
        using namespace std;
        typedef long long ll;
        int main()
        {
        	ll time,h,m,s;
        	scanf("%lld",&time);
        	time/=1000;
        	s=time%60;
        	time/=60;
        	m=time%60;
        	time/=60;
        	h=time%24;
        	printf("%02lld:%02lld:%02lld\n",h,m,s);
        	return 0;
        }
        
        • 0
          @ 2022-1-23 17:31:56

          题目来源

          2021年蓝桥杯省赛第一场F题

          题目链接:http://acm.mangata.ltd/p/P1488

          考点

          暴力、小技巧

          视频讲解

          视频连接:https://www.bilibili.com/video/BV1z44y1s7wD/

          思路

          因为给出的是一个毫秒值,那么我们要将其转化为秒、分钟、小时,注意的是1s=1000ms,其余的进制都是60,别记错了!,关于补0显示:%02d这样的话如果不满两位数,会自动补上的

          代码

          #include<bits/stdc++.h>
          using namespace std;
          //----------------自定义部分----------------
          #define ll long long
          #define mod 1000000009
          #define endl "\n"
          #define PII pair<int,int>
          
          int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
          
          ll ksm(ll a,ll b) {
          	ll ans = 1;
          	for(;b;b>>=1LL) {
          		if(b & 1) ans = ans * a % mod;
          		a = a * a % mod;
          	}
          	return ans;
          }
          
          ll lowbit(ll x){return -x & x;}
          
          const int N = 2e6+10;
          //----------------自定义部分----------------
          int n,m,q,a[N];
          
          int main()
          {
          //	std::ios::sync_with_stdio(false);
          //	std::cin.tie(nullptr);
          //	std::cout.tie(nullptr);
          	ll tm;
          	scanf("%lld",&tm);
          	tm /= 1000;
          	ll s = tm;
          	s %= 60;
          	tm /= 60;
          	ll m = tm;
          	m %= 60;
          	tm /= 60;
          	ll h = tm;
          	h %= 24;
          	printf("%02lld:%02lld:%02lld\n",h,m,s);
          	return 0;
          }
          
          • 1

          Information

          ID
          1561
          Time
          1000ms
          Memory
          256MiB
          Difficulty
          3
          Tags
          # Submissions
          105
          Accepted
          55
          Uploaded By