結果

問題 No.3098 tan 2
ユーザー Syed Shakil Mahmud (Shajib)Syed Shakil Mahmud (Shajib)
提出日時 2023-03-31 22:17:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 697 bytes
コンパイル時間 815 ms
コンパイル使用メモリ 73,464 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 08:22:09
合計ジャッジ時間 1,623 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int I;
    cin >> I;
    double angle = I * M_PI / 180.0;
    double tan_value = tan(angle);
    bool is_rational = false;
    double num = tan_value;
    double den = 1.0;
    for (int i = 0; i < 100; i++) { // limit the number of iterations to prevent infinite loop
        double diff = num - round(num);
        if (abs(diff) < 1e-9) {
            is_rational = true;
            break;
        }
        double next = 1.0 / (diff);
        num = den;
        den = next;
    }
    if (is_rational) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}
0