Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: Pablo Moreno Olalla
- Email address: darthbrevu@yahoo.es
- */
- #include <cstdio>
- #include <string>
- #include <sstream>
- #include <iostream>
- using namespace std;
- unsigned long long leds[]={6,2,5,5,4,5,6,3,7,6};
- unsigned long long accum[]={6,8,13,18,22,27,33,36,43,49};
- unsigned long long times[]={36000,3600,600,60,10};
- unsigned long long accum2[6];
- inline void initA() {
- accum2[5]=accum[9]; //10s
- accum2[4]=6*accum2[5]+10*accum[5]; //1m
- accum2[3]=10*accum2[4]+60*accum[9]; //10m
- accum2[2]=6*accum2[3]+600*accum[5]; //1h
- accum2[1]=10*accum2[2]+3600*accum[9]; //10h
- accum2[0]=24*accum2[2]+accum[1]*36000+leds[2]*14400+accum[9]*7200+accum[3]*3600;
- }
- unsigned long long totalLeds(unsigned secs) {
- unsigned long long d=secs/86400;
- unsigned long long res=accum2[0]*d;
- secs%=86400;
- unsigned long long count;
- for (int i=0;i<5;++i) {
- count=secs/times[i];
- secs%=times[i];
- res+=count*accum2[i+1]+leds[count]*(secs+1);
- if (count>0) res+=times[i]*accum[count-1];
- }
- return res+accum[secs];
- }
- int main(int argc,char **argv) {
- //The first two lines are not strictly necessary, but make the code a little more handy.
- if (argc>=2) freopen(argv[1],"r",stdin);
- if (argc>=3) freopen(argv[2],"w",stdout);
- initA();
- string tmp;
- unsigned long long ull;
- do {
- getline(cin,tmp);
- istringstream iss(tmp);
- iss>>ull;
- if (!iss.fail()) cout<<totalLeds(ull)<<endl;
- } while (!cin.eof());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement