結果

問題 No.8098 tan 2
ユーザー Syed Shakil Mahmud (Shajib)
提出日時 2023-03-31 22:17:37
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 697 bytes
コンパイル時間 685 ms
コンパイル使用メモリ 73,620 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-23 01:01:37
合計ジャッジ時間 1,199 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 12
権限があれば一括ダウンロードができます

ソースコード

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