Created
June 10, 2020 08:20
-
-
Save rabbiabram/6612f997f859b8c64ac277befdcf0c40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; Enter your code here. Read input from STDIN. Print output to STDOUT | |
| ; | |
| (require '[clojure.string :as str]) | |
| ;; (defn ) | |
| (defn read_split [] (map #(Long/parseLong %) (-> (read-line) | |
| (str/split #" ")))) | |
| (defn calc [coefs pows f x] | |
| (let [cp (zipmap coefs pows)] | |
| (reduce-kv (fn [r a b] | |
| (+ r (f (* a (Math/pow x b)))) | |
| ) 0 cp) | |
| ) | |
| ) | |
| (defn rotate [x] | |
| (* x x) | |
| ) | |
| (defn area_calc [delta] | |
| (fn [x] x) | |
| ) | |
| (let [a_n (read_split) | |
| b_n (read_split) | |
| [L R] (read_split) | |
| delta 0.001 | |
| ] | |
| (let [ | |
| sum (reduce + (->> (range L (+ R delta) delta) (map #(calc a_n b_n (fn [x] x) %)))) | |
| area (reduce + (->> (range L (+ R delta) delta) (map #(calc a_n b_n rotate %)))) | |
| ] | |
| (println (* delta sum)) | |
| (println (* delta (* Math/PI area))) | |
| ) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment