Click Here to go back to the homepage.

Friday the 13th Solution:


#include <bits/stdc++.h>
using namespace std;

int main(){
    // #ifndef TESTING
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif 

    int cases;
    cin >> cases;
    while(cases--){
        int days, months;
        cin >> days >> months;
        int sum = 0, count = 0;
        while(months--){
            int daysInMonth;
            cin >> daysInMonth;
            if(daysInMonth > 12 && (sum + 13) % 7 == 6){
                count++;
            }
            sum += daysInMonth;
        }
        cout << count << endl;
    }
    
    return 0;
}