Submission #7460025


Source Code Expand

import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int R = reader.nextInt();
        int N = reader.nextInt();
        int M = reader.nextInt();

        double ans = 0.0;
        for (int i=1; i<N+M; i++) {
            // calc sum of max(length(i), length(i+M))
            double a = 0;
            double b = 0;
            a = Math.sqrt(Math.pow((double)R,2) - Math.pow((double)R-((double)R*2/N*i),2));
            b = Math.sqrt(Math.pow((double)R,2) - Math.pow((double)R-((double)R*2/N*(i-M)),2));
            if (Double.isNaN(a)) a = 0.0;
            if (Double.isNaN(b)) b = 0.0;
            ans += Math.max(a, b)*2;
        }
        System.out.println(ans);
    }
    
    public static void solver() {
        // write logic
    }
    
    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}

Submission Info

Submission Time
Task B - ステップカット
User gahou
Language Java8 (OpenJDK 1.8.0)
Score 200
Code Size 3240 Byte
Status AC
Exec Time 94 ms
Memory 21460 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 16
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt, 00_example_03.txt
All 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 20_hand_01.txt, 20_hand_02.txt, 20_hand_03.txt, 20_hand_04.txt, 20_hand_05.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 71 ms 18900 KB
00_example_02.txt AC 68 ms 17748 KB
00_example_03.txt AC 91 ms 21460 KB
10_rand_01.txt AC 68 ms 21076 KB
10_rand_02.txt AC 68 ms 21204 KB
10_rand_03.txt AC 84 ms 20052 KB
10_rand_04.txt AC 70 ms 19156 KB
10_rand_05.txt AC 74 ms 18516 KB
10_rand_06.txt AC 71 ms 20948 KB
10_rand_07.txt AC 76 ms 18132 KB
10_rand_08.txt AC 75 ms 20564 KB
20_hand_01.txt AC 89 ms 20052 KB
20_hand_02.txt AC 94 ms 18900 KB
20_hand_03.txt AC 92 ms 21204 KB
20_hand_04.txt AC 70 ms 19412 KB
20_hand_05.txt AC 74 ms 21076 KB