Let's Plant Rice Problem Submissions To simulate rice paddy maintenance, a game company decided to use the following function to calculate the evaporation rate of water: rate=1-(- Discussions -)" + d 1+e (0.5) Where: •-how full the rice paddy is at the start of the day, the value of which ranges from 0.0 (0% water level) to 1.0 (100% water level) •d, k, and a-variables that control the rate of evaporation. When a rice paddy is filled with water, the evaporation rate is set for that day, and water would slowly evaporate following this rate. Upon releasing the game, players discovered that if a sweet spot evaporation rate a, with an error margin of 0.1 is used, the water level would be perfect every time and would result in the best quality crop. However, because players were not yet aware of factors d, k and a, they were unable to figure out how to properly set their starting water level to exploit this sweet spot. OSN≤5-10³ 05.51 -0.5 ≤ ≤ 0.5 0≤a,k≤5 After data mining through the game, however, you managed to uncover factors d, k, and a, and you found our that these three factors were arbitrarily set at the start of each day. Moreover, there are indeed days where, no matter what you set your starting water level to, the sweet spot cannot be reached (darn those cheeky game developers). Your task is to write a program that, given the values of d, k, and a, would determine the starting water level that would result in an evaporation rate of for that particular day. On days where a cannot be reached, indicate that "Sweet spot cannot be reached! Those cheeky developers!". Input Format The first line of the input contains an integer N, indicating the number of days you would need to figure out the starting water level for. N lines follow, each containing four space-separated real numbers that correspond to the value of a, d, k, and a.a is the sweet spot evaporation rate. d, k, and a are described in the problem statement. Constraints

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.1: Function And Parameter Declarations
Problem 4E: (Statics) A beam’s second moment of inertia, also known as its area moment of inertia, is used to...
icon
Related questions
Question
100%

LPR Problem Set

Can be answered in C++14, Java 8, or Pypy 3

Let's Plant Rice
Problem
Submissions
Discussions
To simulate rice paddy maintenance, a game company decided to use the following function to calculate the
evaporation rate of water:
rate 1-(-
1
1+e (2-0.5)
-)² + d
Where:
• z-how full the rice paddy is at the start of the day, the value of which ranges from 0.0 (0% water level) to
1.0(100% water level)
• d, k, and a -variables that control the rate of evaporation.
When a rice paddy is filled with water, the evaporation rate is set for that day, and water would slowly
evaporate following this rate.
Upon releasing the game, players discovered that if a sweet spot evaporation rates, with an error margin of
0.1 is used, the water level would be perfect every time and would result in the best quality crop. However,
because players were not yet aware of factors d, k and a, they were unable to figure out how to properly set
their starting water level to exploit this sweet spot.
After data mining through the game, however, you managed to uncover factors d, k, and a, and you found out
that these three factors were arbitrarily set at the start of each day. Moreover, there are indeed days where,
no matter what you set your starting water level to, the sweet spot cannot be reached (darn those cheeky
game developers!). Your task is to write a program that, given the values of d, k, and a, would determine the
starting water level that would result in an evaporation rate of & for that particular day. On days where 8
cannot be reached, Indicate that "Sweet spot cannot be reached! Those cheeky developers!".
Input Format
The first line of the input contains an Integer N, Indicating the number of days you would need to figure out
the starting water level for.
N lines follow, each containing four space-separated real numbers that correspond to the value of 8, d, k, and
a. 8 is the sweet spot evaporation rate. d, k, and a are described in the problem statement.
Constraints
0≤N≤ 5-10³
0≤8≤1
-0.5 ≤ ≤ 0.5
0≤a, k≤5
Output Format
There will be N lines of outputs, each line being the lowest starting water level that would get to within the
acceptable margins for the sweet spot evaporation rate s. Absolute or relative error must not exceed 10-6.
Print "Sweet spot cannot be reached! Those cheeky developers!" (without the quotation marks) If the sweet
spot is impossible to be reached.
Transcribed Image Text:Let's Plant Rice Problem Submissions Discussions To simulate rice paddy maintenance, a game company decided to use the following function to calculate the evaporation rate of water: rate 1-(- 1 1+e (2-0.5) -)² + d Where: • z-how full the rice paddy is at the start of the day, the value of which ranges from 0.0 (0% water level) to 1.0(100% water level) • d, k, and a -variables that control the rate of evaporation. When a rice paddy is filled with water, the evaporation rate is set for that day, and water would slowly evaporate following this rate. Upon releasing the game, players discovered that if a sweet spot evaporation rates, with an error margin of 0.1 is used, the water level would be perfect every time and would result in the best quality crop. However, because players were not yet aware of factors d, k and a, they were unable to figure out how to properly set their starting water level to exploit this sweet spot. After data mining through the game, however, you managed to uncover factors d, k, and a, and you found out that these three factors were arbitrarily set at the start of each day. Moreover, there are indeed days where, no matter what you set your starting water level to, the sweet spot cannot be reached (darn those cheeky game developers!). Your task is to write a program that, given the values of d, k, and a, would determine the starting water level that would result in an evaporation rate of & for that particular day. On days where 8 cannot be reached, Indicate that "Sweet spot cannot be reached! Those cheeky developers!". Input Format The first line of the input contains an Integer N, Indicating the number of days you would need to figure out the starting water level for. N lines follow, each containing four space-separated real numbers that correspond to the value of 8, d, k, and a. 8 is the sweet spot evaporation rate. d, k, and a are described in the problem statement. Constraints 0≤N≤ 5-10³ 0≤8≤1 -0.5 ≤ ≤ 0.5 0≤a, k≤5 Output Format There will be N lines of outputs, each line being the lowest starting water level that would get to within the acceptable margins for the sweet spot evaporation rate s. Absolute or relative error must not exceed 10-6. Print "Sweet spot cannot be reached! Those cheeky developers!" (without the quotation marks) If the sweet spot is impossible to be reached.
Sample Input 0
5
9.7119 -8.1286 2.9930 4.0577
0.9219 8.1963 2.7140 4.3201
0.2692 -8.0695 2.9132 1.6116
0.3601 -8.1771 0.6213 1.1878
0.3492 -8.3865 3.8889 2.5649
Sample Output 0
0.697784503837
0.887988531876
0.921929270258
0.645118392198
0.599166842326
Explanation 0
On the first day, a starting water level of 0.6977845, with d= -0.1206, k = 2.9930, and a = 4.0577 will
result in an evaporation rate within 10-6 absolute error of 0.7119. The same is true for the other days.
Sample Input 1
7
0.2772 8.2253 4.2550 1.9385
0.2807 -8.2682 1.5963 1.6372
0.9855 8.8522 2.5857 2.2608
0.3196 -8.2528 2.7628 8.9047
9.6853 -8.2366 3.6572 2.5567
9.7148 -8.1846 0.9737 4.1721
0.9411 -8.1378 2.8860 2.6794
Sample Output 1
Sweet spot cannot be reached! Those cheeky developers!
0.793247141838
0.387482764833
0.346837169388
0.353158812485
0.817511673628
Sweet spot cannot be reached! Those cheeky developers!
Explanation 1
-16
On the first day, it is impossible to reach an evaporation rate within 10 of 0.2772 given
d = 0.2253, k = 4.2550, and a = 1.9385.
1-import java.io. BufferedReader;
2 import java.io.InputStreamReader;
3
4 public class Solution {
5+
6
7
8
10-
11
12
PERSPERSA******
13-
14
15
16
17-
18-
28
29
public static void main(String[] args) throws Exception {
BufferedReader br = new Buffered Reader (new InputStreamReader (System.in));
StringBuilder sb = new StringBuilder();
}
int n = Integer.parseInt(br.readLine().trim());
double[][] vals = new double[n] [4];
for (int i = 0; i<n; i++){
}
String[] parts = br.readLine().trim().split(" ");
for (int j = 0; j < 4; j++) {
vals[i][j] = Double.parseDouble (parts[j]);
}
doubles vals[1][0];
double d = vals[1][1];
double k
double a
solve(s,d,k,a,sb);
System.out.print(sb);
}
vals[1] [2];
vals[1] [3];
Ja
public static void solve (double s, double d, double k, double a, StringBuilder sb) {
// compute and append answer to StringBuilder here
Transcribed Image Text:Sample Input 0 5 9.7119 -8.1286 2.9930 4.0577 0.9219 8.1963 2.7140 4.3201 0.2692 -8.0695 2.9132 1.6116 0.3601 -8.1771 0.6213 1.1878 0.3492 -8.3865 3.8889 2.5649 Sample Output 0 0.697784503837 0.887988531876 0.921929270258 0.645118392198 0.599166842326 Explanation 0 On the first day, a starting water level of 0.6977845, with d= -0.1206, k = 2.9930, and a = 4.0577 will result in an evaporation rate within 10-6 absolute error of 0.7119. The same is true for the other days. Sample Input 1 7 0.2772 8.2253 4.2550 1.9385 0.2807 -8.2682 1.5963 1.6372 0.9855 8.8522 2.5857 2.2608 0.3196 -8.2528 2.7628 8.9047 9.6853 -8.2366 3.6572 2.5567 9.7148 -8.1846 0.9737 4.1721 0.9411 -8.1378 2.8860 2.6794 Sample Output 1 Sweet spot cannot be reached! Those cheeky developers! 0.793247141838 0.387482764833 0.346837169388 0.353158812485 0.817511673628 Sweet spot cannot be reached! Those cheeky developers! Explanation 1 -16 On the first day, it is impossible to reach an evaporation rate within 10 of 0.2772 given d = 0.2253, k = 4.2550, and a = 1.9385. 1-import java.io. BufferedReader; 2 import java.io.InputStreamReader; 3 4 public class Solution { 5+ 6 7 8 10- 11 12 PERSPERSA****** 13- 14 15 16 17- 18- 28 29 public static void main(String[] args) throws Exception { BufferedReader br = new Buffered Reader (new InputStreamReader (System.in)); StringBuilder sb = new StringBuilder(); } int n = Integer.parseInt(br.readLine().trim()); double[][] vals = new double[n] [4]; for (int i = 0; i<n; i++){ } String[] parts = br.readLine().trim().split(" "); for (int j = 0; j < 4; j++) { vals[i][j] = Double.parseDouble (parts[j]); } doubles vals[1][0]; double d = vals[1][1]; double k double a solve(s,d,k,a,sb); System.out.print(sb); } vals[1] [2]; vals[1] [3]; Ja public static void solve (double s, double d, double k, double a, StringBuilder sb) { // compute and append answer to StringBuilder here
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning