Language: C++

#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

const int M = 7 * 24 * 60;

int s, n, t, p, m, lt, rt;
string weekday, time, data[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};

double my_pow(double a, int b){
  double res = 1.0;
  for(int i=0;i<b;i++) res *= a;
  return res;
}

int calc(int s_time){
  int sum = 0;
  for(int i=0;i<m;i++,s_time=(s_time+t)%M){
    int f_time = s_time + s;
    bool f = false;
    for(int j=0;j<7;j++){
      if(weekday == "All" || weekday == data[j]){
        if(time == "All"){
          lt = 24 * 60 * j;
          rt = lt + 24 * 60;
          if(lt <= s_time && f_time < rt) f = true; 
        }
        if(time == "Day"){
          lt = 24 * 60 * j + 6 * 60;
          rt = lt + 12 * 60;
          if(lt <= s_time && f_time < rt) f = true;
        }
        if(time == "Night"){
          lt = 24 * 60 * j;
          rt = lt + 6 * 60;
          if(lt <= s_time && f_time < rt) f = true;
          lt = 24 * 60 * j + 18 * 60;
          rt = lt + 6 * 60;
          if(lt <= s_time && f_time < rt) f = true;
        }
      }
    }
    if(f) sum++;
  }
  return sum;
}

main(){
  while(cin >> s >> n >> t >> weekday >> time >> p >> m && (s|n|t|p|m) && weekday != "None" && time != "None"){
    int ans = 0;
    for(int i=0;i<7;i++) for(int j=0;j<24;j++) ans = max(ans, calc(i * 24 * 60 + j * 60));
    printf("%.10f\n", 1.0 - my_pow(1.0 - 1.0 / p, n * ans));
  }
}

Compiler output:
a.cc:10:17: error: 'std::string time' redeclared as different kind of entity
   10 | string weekday, time, data[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
      |                 ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'int calc(int)':
a.cc:24:41: error: reference to 'data' is ambiguous
   24 |       if(weekday == "All" || weekday == data[j]){
      |                                         ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:10:23: note:                 'std::string data [7]'
   10 | string weekday, time, data[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
      |                       ^~~~
a.cc:25:17: error: comparison between distinct pointer types 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} and 'const char*' lacks a cast
   25 |         if(time == "All"){
      |            ~~~~~^~~~~~~~
a.cc:30:17: error: comparison between distinct pointer types 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} and 'const char*' lacks a cast
   30 |         if(time == "Day"){
      |            ~~~~~^~~~~~~~
a.cc:35:17: error: comparison between distinct pointer types 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} and 'const char*' lacks a cast
   35 |         if(time == "Night"){
      |            ~~~~~^~~~~~~~~~
a.cc: At global scope:
a.cc:50:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:51:39: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>' and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'})
   51 |   while(cin >> s >> n >> t >> weekday >> time >> p >> m && (s|n|t|p|m) && weekday != "None" && time != "None"){
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~ ~~~~
      |                            |             |
      |                            |             time_t(time_t*) noexcept {aka long int(long int*) noexcept}
      |                            std::basic_istream<char>
In file included from /usr/include/c++/14/iostream:42:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  170 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:170:7: note:   conversion of argument 1 would be ill-formed:
a.cc:51:42: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'}
   51 |   while(cin >> s >> n >> t >> weekday >> time >> p >> m && (s|n|t|p|m) && weekday != "None" && time != "None"){
      |                                          ^~~~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
  174 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/14/istream:174:7: note:   conversion of argument 1 would be ill-formed:
a.cc:51:42: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'short int' [-fpermissive]
   51 |   while(cin >> s >> n >> t >> weekday >> time >> p >> m && (s|n|t|p|m) && weekday != "None" && time != "None"){
      |                                          ^~~~
      |                                          |
      |                                          time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
a.cc:51:42: error: cannot bind rvalue '(short int)time' to 'short int&'
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  177 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:177:7: note:   conversion of argument 1 would be ill-formed:
a.cc:51:42: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'short unsigned int' [-fpermissive]
   51 |   while(cin >> s >> n >> t >> weekday >> time >> p >> m && (s|n|t|p|m) && weekday != "None" && time != "None"){
      |                                          ^~~~
      |                                          |
      |                                          time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
a.cc:51:42: error: cannot bind rvalue '(short unsigned int)time' to 'short unsigned int&'
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
  181 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/14/istream:181:7: note:   conversion of argument 1 would be ill-formed:
a.cc:51:42: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'int' [-fpermissive]
   51 |   while(cin >> s >> n >> t >> weekday >> time >> p >> m && (s|n|t|p|m) && weekday != "None" && time != "None"){
      |                                          ^~~~
      |                                          |
      |                                          time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
a.cc:51:42: error: cannot bind rvalue '(int)time' to 'int&'
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  184 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:184:7: note:   conversion of argument 1 would be ill-formed:
a.cc:51:42: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'unsigned int' [-fpermissive]
   51 |   while(cin >> s >> n >> t >> weekday >> time >> p >> m && (s|n|t|p|m) && weekday != "None" && time != "None"){
      |                                          ^~~~
      |                                          |
      |                                          time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
a.cc:51:42: error: cannot bind rvalue '(unsigned int)time' to 'unsigned int&'
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  188 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:188:7: note:   conversion of argument 1 would be ill-formed:
a.cc:51:42: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'long int' [-fpermissive]
   51 |   while(cin >> s >> n >> t >> weekday >> time >> p >> m && (s|n|t|p|m) && weekday != "None" && time != "None"){
      |                                          ^~~~
      |                                          |
      |                                          time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
a.cc:51:42: error: cannot bind rvalue '(long int)time' to 'long int&'
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  192 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:192:7: note:   conversion of argument 1 would be ill-formed:
a.cc:51:42: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'long unsigned int' [-fpermissive]
   51 |   while(cin >> s >> n >> t >> weekday >> time >> p >> m && (s|n|t|p|m) && weekday != "None" && time != "None"){
      |                                          ^~~~
      |