ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 270-A, *1100
    코드포스 2021. 7. 22. 21:04
     

    Problem - 270A - Codeforces

     

    codeforces.com

    문제

    • 매번 $a^{\circ}(0<a<180)$를 회전하는 로봇의 자취가 정다각형이 될 수 있는가?
    • $t(0<t<180)$번 답을 출력한다

     

    풀이1

    모든 정다각형은 삼각형으로 쪼갤 수 있다
    로봇의 자취가 정다각형이고 $n \in \mathbb{N}$개의 삼각형으로 쪼개진다면,
    이 정다각형은 정$(n+2)$각형이고 다음식을 만족한다(내각의 크기를 서로 다른방식으로 구함)
    $$180n = a(n+2)$$
    정리하면
    $$n=\frac{2a}{180-a}\in \mathbb{N}$$

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    #include <bits/stdc++.h>
    #define endl "\n"
    using namespace std;
     
    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0), cout.tie(0);
     
        int t;
        cin >> t;
        int a;
        while(t--){
            cin >> a;
            cout << (a >= 60 && 2*a%(180-a) == 0"YES" : "NO"<< endl;
        }
        return 0;

     

    풀이2

    $$(\mathrm{Sum\ of\ the\ exterior\ angles\ of\ a\ convex\ polygon}) = 360^{\circ}$$
    $pf)$
    볼록한 $n$각형은 $(n-2)$개의 삼각형으로 나뉘므로 내각의 합은 $180(n-2)^{\circ}$
    각각의 꼭짓점에 대해 $\mathrm{External\ angle+Internal\ angle} = 180^{\circ}$이므로
    (내각의 합)+(외각의 합) = $180n^{\circ}$ $\square$

    위 정리를 이용하면 로봇의 자취가 정$n$각형일 필요충분조건은
    $$(180-a)n=360$$

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    #include <bits/stdc++.h>
    #define endl "\n"
    using namespace std;
     
    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0), cout.tie(0);
     
        int t;
        cin >> t;
        int a;
        while(t--){
            cin >> a;
            cout << (360%(180-a) == 0"YES""NO"<< endl;
        }
     
        return 0;

    '코드포스' 카테고리의 다른 글

    456-A, *1100  (0) 2021.07.23
    519-B, *1100  (0) 2021.07.23
    363-B, *1100  (0) 2021.07.22
    706-B, *1100  (0) 2021.07.22
    158-B, *1100  (0) 2021.07.21

    댓글

Designed by Tistory.