---
# System prepended metadata

title: '*A - Doom''s Day Algorithm*'
tags: [CPE-數學計算, CPE]

---

###### tags: `CPE-數學計算`
# *A - Doom's Day Algorithm*
## 題目：
![](https://i.imgur.com/EfqIa6v.png)
![](https://i.imgur.com/vPcwrO1.png)

>用總天數%7取餘數就會是星期幾了
>
>Month[]中的0是初始值，讓Month可以配合實際月份，days+d+5中的+5是校正數值
```
#include <bits/stdc++.h>

using namespace std;

int main() {
    int kase;
    cin >> kase;
    string Day[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
    int Month[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    while (kase--) {
        int m, d;
        cin >> m >> d;
        int days=0;
        for(int i=0;i<m;i++)
            days+=Month[i];
        int w=(days+d+5)%7;
        cout<<Day[w]<<endl;
    }
    return 0;
}
```