Submission #30762032


Source Code Expand

#include <cmath>
#include <cstdio>
#include <cstring>

constexpr double pi = std::acos(-1.0);

using f64 = double;
using u64 = unsigned long;

u64 to_bits(f64 f) {
  u64 u;
  std::memcpy(&u, &f, sizeof f);
  return u;
}

f64 from_bits(u64 u) {
  f64 f;
  std::memcpy(&f, &u, sizeof u);
  return f;
}

u64 f2u(f64 f) {
  u64 u = to_bits(f);
  return ((u >> 63) == 1)? ~u: u ^ (1uL << 63);
}

f64 u2f(u64 u) {
  return from_bits(((u >> 63) == 1)? u ^ (1uL << 63): ~u);
}

int main() {
  double a, b, c;
  scanf("%lf %lf %lf", &a, &b, &c);

  auto f = [=](auto x) { return a * x + b * std::sin(c * x * pi); };
  
  u64 lb = f2u(0.0);
  u64 ub = f2u(1.0e9);
  while (ub - lb > 1) {
    u64 mid_u = lb + (ub - lb) / 2;
    f64 mid = u2f(mid_u);
    ((f(mid) < 100.0)? lb: ub) = mid_u;
  }
  f64 res = u2f(lb);
  printf("%.12f\n", res);
}

Submission Info

Submission Time
Task D - 高橋君ボール1号
User rsk0315
Language C++ (GCC 9.2.1)
Score 100
Code Size 879 Byte
Status AC
Exec Time 5 ms
Memory 2640 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:33:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   33 |   scanf("%lf %lf %lf", &a, &b, &c);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 2
AC × 17
Set Name Test Cases
Sample example_0.txt, example_1.txt
All example_0.txt, example_1.txt, random_0.txt, random_1.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt, special_0.txt, special_1.txt, special_2.txt, example_0.txt, example_1.txt
Case Name Status Exec Time Memory
example_0.txt AC 5 ms 2436 KiB
example_1.txt AC 1 ms 2444 KiB
random_0.txt AC 1 ms 2456 KiB
random_1.txt AC 1 ms 2456 KiB
random_2.txt AC 1 ms 2424 KiB
random_3.txt AC 1 ms 2424 KiB
random_4.txt AC 1 ms 2584 KiB
random_5.txt AC 1 ms 2424 KiB
random_6.txt AC 3 ms 2428 KiB
random_7.txt AC 1 ms 2536 KiB
random_8.txt AC 1 ms 2432 KiB
random_9.txt AC 1 ms 2456 KiB
special_0.txt AC 4 ms 2424 KiB
special_1.txt AC 1 ms 2540 KiB
special_2.txt AC 1 ms 2640 KiB