結果

問題 No.1224 I hate Sqrt Inequality
ユーザー root__786
提出日時 2020-09-11 22:20:30
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,915 bytes
コンパイル時間 1,716 ms
コンパイル使用メモリ 195,916 KB
最終ジャッジ日時 2025-01-14 10:42:45
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

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