Notice
Recent Posts
Recent Comments
- Today
- Total
01-11 13:35
Tags
- ์๋ฐ
- ๋ค์ต์คํธ๋ผ
- spring
- ๋ฌธ๋ฒ
- ์๋ฃ๊ตฌ์กฐ
- leetcode
- ๊ทธ๋ฆฌ๋
- ๋ฐฑ์๋
- pytorch
- ํ๋ก๊ทธ๋๋จธ์ค
- Algorithm
- ์ธํด
- PS
- Graph
- ์กธ์ ์ํ
- ์์์ ๋ ฌ
- ๊ตฌํ
- array
- OOP
- CS
- ์๋ฐ์์ ์
- ๋ฐฑ์ค
- dp
- java
- tree
- MST
- ๋ฒจ๋งํฌ๋
- database
- BFS
- ๋ฐ์ดํฐ๋ฒ ์ด์ค
Link
Partially Committed
[ํ๋ก๊ทธ๋๋จธ์ค] 2016๋ ๋ณธ๋ฌธ
728x90
๋ฐ์ํ
SMALL
https://programmers.co.kr/learn/courses/30/lessons/12901
2016๋ 1์ 1์ผ์ ๊ธ์์ผ์ด๋ฏ๋ก,
2016 ๋ A์ B์ผ ์ A - 1 ์๊น์ง์ ์ผ ์ + B ๋ฅผ ๋ํ ๊ฐ data ๋ฅผ 7๋ก ๋๋ ๋๋จธ์ง์ ๋ฐ๋ผ์ ์์ผ์ ์ ์ ์๋ค.
[C++]
#include <string>
#include <vector>
using namespace std;
/*
(1, 31) (2,29) (3, 31) (4, 30) (5, 31)
(6, 30) (7, 31) (8, 31) (9, 30) (10, 31)
(11, 30) (12,31)
*/
//2016. 01. 01 : FRI
string solution(int a, int b) {
string answer = "";
int date = 0;
int day_arr[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
string arr[] = { "FRI", "SAT", "SUN", "MON", "TUE", "WED", "THU" };
for (int i = 0; i < a-1; i++)
{
date += day_arr[i];
}
date += b;
if (date % 7 - 1 != -1)
answer = arr[date % 7 - 1];
else // date % 7 == 0 ์ด๋ฉด arr[-1] ์ด ๋๋ ๊ฒ์ ๋ํ ์์ธ์ฒ๋ฆฌ
answer = arr[6];
return answer;
}
728x90
๋ฐ์ํ
LIST
'๐ฅ Algorithm || ๋ฌธ์ ํ์ด > PS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[์๊ฐ ์ฝ๋ ์ฑ๋ฆฐ์ง ์์ฆ3] ๋๋จธ์ง๊ฐ 1์ด ๋๋ ์ ์ฐพ๊ธฐ (0) | 2022.07.05 |
---|---|
[์ํด๋ฆฌ ์ฑ๋ฆฐ์ง] ์ต์์ง์ฌ๊ฐํ (0) | 2022.07.04 |
[์๊ฐ ์ฝ๋ ์ฑ๋ฆฐ์ง ์์ฆ1] ๋ ๊ฐ ๋ฝ์์ ๋ํ๊ธฐ (0) | 2022.07.04 |
[Summer/Winter Coding(~2018)] ์์ฐ (0) | 2022.07.04 |
[์๊ฐ ์ฝ๋ ์ฑ๋ฆฐ์ง ์์ฆ1] 3์ง๋ฒ ๋ค์ง๊ธฐ (0) | 2022.07.04 |
Comments