結果

問題 No.2271 平方根の13桁精度近似計算
ユーザー 👑 chro_96chro_96
提出日時 2023-04-15 00:21:51
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 847 bytes
コンパイル時間 529 ms
コンパイル使用メモリ 31,360 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-18 21:48:57
合計ジャッジ時間 3,131 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 8 ms
5,376 KB
testcase_11 AC 6 ms
5,376 KB
testcase_12 AC 21 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 5 ms
5,376 KB
testcase_16 AC 22 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 6 ms
5,376 KB
testcase_23 AC 19 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 3 ms
5,376 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 3 ms
5,376 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 3 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 7 ms
5,376 KB
testcase_34 AC 21 ms
5,376 KB
testcase_35 WA -
testcase_36 AC 220 ms
5,376 KB
testcase_37 AC 3 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  long long n = 0LL;
  int e = 0;
  
  int res = 0;
  
  long long ans = -1LL;
  long long d = 1LL;
  
  long long tmp = 0LL;
  long long g[625][625] = {};
  int gcnt[25] = {};
  
  res = scanf("%lld", &n);
  res = scanf("%d", &e);
  
  while (e > 0) {
    d *= 5LL;
    e--;
  }
  
  if (n > 0LL) {
    n %= d;
  } else {
    n = (d-(-n)%d)%d;
  }
  
  for (int i = 0; i < 625; i++) {
    g[(i*i)%625][gcnt[(i*i)%625]] = (long long)i;
    gcnt[(i*i)%625]++;
  }
  
  while (ans < 0LL && tmp < d && tmp <= (1LL<<29LL)) {
    for (int i = 0; i < gcnt[(int)(n%625LL)]; i++) {
      long long tmp2 = tmp+g[(int)(n%625LL)][i];
      if ((tmp2*tmp2)%d == n) {
        ans = tmp2;
      }
    }
    tmp += 625LL;
  }
  
  if (ans < 0LL) {
    printf("NaN\n");
  } else {
    printf("%lld\n", ans);
  }
  
  return 0;
}
0