+ Нов въпрос
Tsveten.kavrakov 7 Точки

## задача 9. *Spice Must Flow

Условието е:

Write a program that calculates the total amount of spice that can be extracted from a source.
The source has a starting yield, which indicates how much spice can be mined on the first day. After it has been mined for a day, the yield drops by 10, meaning on the second day it’ll produce 10 less spice than on the first, on the third day 10 less than on the second, and so on (see examples).
A source is considered profitable only while its yield is at least 100 – when less than 100 spice is expected in a day, abandon the source.

The mining crew consumes 26 spice every day at the end of their shift and an additional 26 after the mine has been exhausted. Note that the workers cannot consume more spice than there is in storage.

When the operation is complete, print on the console on two separate lines how many days the mine has operated and the total amount of spice extracted.

### Input

You will receive a number, representing the starting yield of the source.

### Output

Print on the console on two separate lines how many days the mine has operated and the total amount of spice extracted.

### Constraints

• The starting yield will be a positive integer within range [0 … 2 147 483 647]

Моето решение е :

```import java.util.Scanner;
public class Main {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

int startingYield=Integer.parseInt(scanner.nextLine());
int exstractedYeld=startingYield;
int days=0;
int total=0;
while(exstractedYeld>=100){
days++;
total=total+exstractedYeld-26;
exstractedYeld-=10;
}
if (exstractedYeld>26){
total-=26;
}
System.out.println(days);
System.out.println(total);
}
}```

Явно пропускам нещо в условието , защото ми дава един грешен отговор и 85 точки.

Лошото е ,че не дава входните данни , с които се прави теста, за да разбера къде бъркам.

Нямой може ли да даде решение със 100 точки

Тагове:
0
Tsveten.kavrakov 7 Точки

Koлеги, открих грешката си.

Промених последната проверка:

`if (exstractedYeld>=26 && days>0)`

и вече дава 100 точки.

```
```
0