Language: C++

#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>
#include <cassert>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find() != (s).end())
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,0,n)

#define SUN 0
#define MON 1
#define TUE 2
#define WED 3
#define THU 4
#define FRI 5
#define SAT 6

enum times {
	ALL, DAY, NIGHT
};

int possible_day;
times possible_time;
bool in_span(int d, int h, int m)
{
	if(possible_day == -1) { // ALL
		if(possible_time == ALL) {
			return true;
		} else if (possible_time == DAY) {
			return 6 <= h && h < 18;
		} else {
			return 18 <= h || h < 6;
		}
	} else {
		if(possible_time == ALL) {
			return d == possible_day;
		} else if (possible_time == DAY) {
			return d == possible_day && 6 <= h && h < 18;
		} else {
			return (d == possible_day && 18 <= h) || (d == (possible_day + 1) % 7 && h < 6);
			// return (d == possible_day && (18 <= h || h < 6));
		}
	}
}

void proceed(int minutes, int* cday, int* ch, int* cm)
{
	int tm = *cm + minutes;
	int th = *ch + (tm / 60);
	*cday = (*cday + th / 24) % 7;
	*ch = th % 24;
	*cm = tm % 60;
}


int main()
{
	int s, n, t;
	string weekday, time;
	cout.precision(16);
	int p, m;
	while( cin >> s >> n >> t >> weekday >> time >> p >> m, s | n | t | p | m) {
		if(weekday == "All") {
			possible_day = -1;
		}
		if(weekday == "Sun") {
			possible_day = SUN;
		}
		if(weekday == "Mon") {
			possible_day = MON;
		}
		if(weekday == "Tue") {
			possible_day = TUE;
		}
		if(weekday == "Wed") {
			possible_day = WED;
		}
		if(weekday == "Thu") {
			possible_day = THU;
		}
		if(weekday == "Fri") {
			possible_day = FRI;
		}
		if(weekday == "Sat") {
			possible_day = SAT;
		}
		if(time == "All") {
			possible_time = ALL;
		}
		if(time == "Day") {
			possible_time = DAY;
		}
		if(time == "Night") {
			possible_time = NIGHT;
		}

		ULL max_count = 0;
		FOR (sday, 0, 7) {
			FOR (sh, 0, 24) {
				FOR (sm, 0, 60) {
					int cday = sday, ch = sh, cm = sm;
					ULL change_cnt = 0;
					REP(stage, m) {
						bool changable = false;
						if (in_span(cday, ch, cm)) {
							changable = true;
						}
						proceed(s, &cday, &ch, &cm);
						if (changable && in_span(cday, ch, cm)) {
							++change_cnt;
						}
						proceed(t-s, &cday, &ch, &cm);
					}
					max_count = max(max_count, change_cnt);
				}
			}
		}
		cout << 1.0 - pow(1 - 1.0/p, n * max_count) << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:122:17: error: 'ULL' was not declared in this scope; did you mean 'ALL'?
  122 |                 ULL max_count = 0;
      |                 ^~~
      |                 ALL
a.cc:127:44: error: expected ';' before 'change_cnt'
  127 |                                         ULL change_cnt = 0;
      |                                            ^~~~~~~~~~~
      |                                            ;
a.cc:135:59: error: 'change_cnt' was not declared in this scope
  135 |                                                         ++change_cnt;
      |                                                           ^~~~~~~~~~
a.cc:139:41: error: 'max_count' was not declared in this scope
  139 |                                         max_count = max(max_count, change_cnt);
      |                                         ^~~~~~~~~
a.cc:139:68: error: 'change_cnt' was not declared in this scope
  139 |                                         max_count = max(max_count, change_cnt);
      |                                                                    ^~~~~~~~~~
a.cc:143:50: error: 'max_count' was not declared in this scope
  143 |                 cout << 1.0 - pow(1 - 1.0/p, n * max_count) << endl;
      |                                                  ^~~~~~~~~