Skip to content

Instantly share code, notes, and snippets.

@not522
Created June 23, 2013 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save not522/5845325 to your computer and use it in GitHub Desktop.
Save not522/5845325 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
int main() {
while (true) {
int s, n, t, p, m;
string day, time;
cin >> s >> n >> t >> day >> time >> p >> m;
if (s == 0) break;
bool allday, alltime;
allday = (day == "All");
alltime = (time == "All");
int T;
long long cnt = 0;
rep (_T, 1440 * 7) {
T = _T;
long long c = 0;
rep (mm, m) {
bool flag = true;
rep (tt, t) {
++T;
if (tt < s) {
if (allday && alltime) {
} else if (allday && !alltime) {
if (T % (24 * 60) >= (12 * 60)) flag = false;
} else if (!allday && alltime) {
if (T % (24 * 60 * 7) >= (24 * 60)) flag = false;
} else {
if (time == "Day") {
if (T % (24 * 60 * 7) >= (12 * 60)) flag = false;
} else {
int t2 = T % (24 * 60 * 7);
if (!((t2 < 6 * 60) || (18 * 60 < t2 &&t2 < 24 * 60))) flag = false;
}
}
}
}
if (flag) c += n;
}
cnt = max(cnt, c);
}
double res = 1 - pow(1.0 - 1.0 / p, cnt);
printf("%.12lf\n", res);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment