結果

問題 No.1224 I hate Sqrt Inequality
ユーザー root__786root__786
提出日時 2020-09-11 22:20:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,915 bytes
コンパイル時間 1,916 ms
コンパイル使用メモリ 199,636 KB
実行使用メモリ 9,100 KB
最終ジャッジ日時 2023-08-27 15:06:33
合計ジャッジ時間 5,569 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,756 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long
void PrintPeriodic(int num, int denom)
{
        // Print integral part and decimal point.
       // printf("%d/%d = %d.", num, denom, num / denom);
        num %= denom;
 
        // Loop until periodic part is found.
        int found = -1;
        vector <int> seen, digits;
        for (;;) {
                int cur = (num * 10),
                        cur_rem = cur % denom;
                for (int i = 0; i < seen.size(); i++) {
                        if (seen[i] == cur_rem) {
                                found = i;
                                break;
                        }
                }
                if (found != -1) {
                        break;
                } else {
                        seen.push_back(cur_rem);
                        digits.push_back(cur / denom);
                        num = cur_rem;
                }
        }
    int yy=0;
 
        // Handle special case: periodic part is only zero.
        if (num == 0) {
 
                for (int i = 0; i <= found; i++) {
                       // printf("%d", digits[i]);
                }
                //printf("(0)\n");
 
        } 
    else {
                // Print pre-periodic part.
                for (int i = 0; i < found; i++) {
                        //printf("%d", digits[i]);
                }
 
                // Print periodic part.
                //printf("(");
            yy=0;
                for (int i = found; i < digits.size() && i < found+50; i++) {
                        //printf("%d", digits[i]);
                    yy++;
                }
        }
 
       
        if(yy>=1) cout<<"Yes";
        else cout<<"No";
}
signed main()
{
        int n, denom;
        while (cin>>n>>denom) {
                PrintPeriodic(n, denom);
        }
        return 0;
}
0