LoginSignup
1
0

More than 3 years have passed since last update.

ABC - 010 - A&B&C

Posted at

AtCoder ABC 010 A&B&C

AtCoder - 010

A - ハンドルネーム

    private void solveA() {
        out.println(next() + "pp");
    }

B - 花占い

  • 最初分岐して・・・ってやったけど、よく考えたら2と3の最小公倍数の6の余りで分岐したほうが読みやすかった
    • コメントアウトしているif文の方もACではある
    private void solveB() {
        int n = nextInt();
        int[] wk = IntStream.range(0, n).map(i -> nextInt()).toArray();
        int res = Arrays.stream(wk).reduce(0, (sum, i) -> {
            switch (i % 6) {
            case 1:
                return sum;
            case 2:
                return ++sum;
            case 3:
                return sum;
            case 4:
                return ++sum;
            case 5:
                return sum += 2;
            case 0:
                return sum += 3;
            }
            //          if (i % 2 == 1) {
            //              switch (i % 3) {
            //              case 0:
            //              case 1:
            //                  return sum;
            //              case 2:
            //                  return sum += 2;
            //              }
            //
            //          } else {
            //              switch (i % 3) {
            //              case 0:
            //                  return sum += 3;
            //              case 1:
            //              case 2:
            //                  return ++sum;
            //              }
            //          }

            return sum;
        });

        out.println(res);
    }

C - 浮気調査

  • 三平方の定理を久しぶりに見た
  • ごり押しでも通るんだーって思った後に解法見たら楕円の定理でも解けるとな。。。わからん。。。
    private void solveC() {
        int sX = nextInt();
        int sY = nextInt();
        int gX = nextInt();
        int gY = nextInt();
        int t = nextInt();
        int v = nextInt();
        int n = nextInt();

        for (int i = 0; i < n; i++) {
            int tmpX = nextInt();
            int tmpY = nextInt();
            double total = (Math.hypot(Math.abs(tmpX - sX), Math.abs(tmpY - sY))
                    + Math.hypot(Math.abs(tmpX - gX), Math.abs(tmpY - gY)));
            if (total <= t * v) {
                out.println("YES");
                return;
            }
        }

        out.println("NO");
    }
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0