結果

問題 No.2271 平方根の13桁精度近似計算
ユーザー 👑 chro_96chro_96
提出日時 2023-04-14 23:19:24
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 985 ms / 2,000 ms
コード長 838 bytes
コンパイル時間 926 ms
コンパイル使用メモリ 31,104 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 21:00:27
合計ジャッジ時間 5,915 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 0 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 96 ms
5,376 KB
testcase_11 AC 70 ms
5,376 KB
testcase_12 AC 409 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 66 ms
5,376 KB
testcase_16 AC 413 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 21 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 10 ms
5,376 KB
testcase_22 AC 85 ms
5,376 KB
testcase_23 AC 409 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 449 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 87 ms
5,376 KB
testcase_34 AC 403 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 985 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
testcase_38 AC 0 ms
5,376 KB
testcase_39 AC 20 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[25][25] = {};
  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 < 25; i++) {
    g[(i*i)%25][gcnt[(i*i)%25]] = (long long)i;
    gcnt[(i*i)%25]++;
  }
  
  while (ans < 0LL && tmp < d && tmp <= (1LL<<29LL)) {
    for (int i = 0; i < gcnt[(int)(n%25LL)]; i++) {
      long long tmp2 = tmp+g[(int)(n%25LL)][i];
      if ((tmp2*tmp2)%d == n) {
        ans = tmp2;
      }
    }
    tmp += 25LL;
  }
  
  if (ans < 0LL) {
    printf("NaN\n");
  } else {
    printf("%lld\n", ans);
  }
  
  return 0;
}
0