Created
January 10, 2013 18:38
-
-
Save notmahi/4504623 to your computer and use it in GitHub Desktop.
Bangladesh Informatics Olympiad Practice Contest - 1 - M
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
#include <string> | |
int sec; | |
int mn, hr, day, mth, yr; | |
using namespace std; | |
int main() | |
{ | |
int t, tt; | |
cin >> t; | |
for (int i =0; i< t; i++) | |
{ | |
cin >> sec; | |
cout << "Case "<< i+1 << ":"; | |
mn = sec / 60; | |
sec %= 60; | |
hr = mn / 60; | |
mn %= 60; | |
day = hr / 24; | |
hr %= 24; | |
mth = day / 30; | |
day %= 30; | |
yr = mth / 12; | |
mth %= 12; | |
//cout << yr << ' ' << mth << ' '<< day << ' ' << hr << ' ' << mn << ' ' << sec; | |
if (yr == 1 ) cout << " 1 year"; | |
else if (yr > 1) cout << ' ' << yr << " years"; | |
if (mth == 1 ) cout << " 1 month"; | |
else if (mth > 1) cout <<' '<< mth << " months"; | |
if (day == 1 ) cout << " 1 day"; | |
else if (day > 1) cout <<' '<< day << " days"; | |
if (hr == 1 ) cout << " 1 hour"; | |
else if (hr > 1) cout <<' '<< hr << " hours"; | |
if (mn == 1 ) cout << " 1 minute"; | |
else if (mn > 1) cout <<' '<< mn << " minutes"; | |
if (sec == 1 ) cout << " 1 second"; | |
else if (sec > 1) cout <<' '<< sec << " seconds"; | |
cout <<'\n'; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment