Import Java.util.Scanner; /** * Bull has a fish tank. Inside the fish tank already has n fish, each fish's size is fishsize[i] (1≤i≤* N, all is the positive whole number), the Cow Ox now wants to put the newly caught fish into the fish tank. There is a ones law in the fish tank. After observation, cattle and cattle found that a fish a size of another fish b size of twice times to 10 times times (* including twice times the size and 10 times times the size), fish A will eat fish B. With this in mind, cattle to be put into the fish to be guaranteed: 1, put in the fish is safe, will not be eaten by other fish * 2, this fish can not eat other fish in the tank inside the fish have been together for a long time, do not consider their mutual predation.
Now know the size of the new fish into the range [Minsize,maxsize] (considering the size of the fish is an integer representation), * Cattle want to know how many sizes of fish can be put into the fish tank.
* * * @author pomay * */public class Nowcode_manyfish {public int fishnum (int minsize, int maxSize, int fishsize[])
{int count = 0;
Boolean flag = true; for (int i = minsize i <= maxSize, i++) {for (int j = 0; J < Fishsize.length; J + +) {//The new fish is bigger and bigger than this one.
2 to 10 times times, eaten if (i >= fishsize[j] * 2 && i <= fishsize[j] * {flag = false;
Break //The new fish is smaller and just 2 to 10 times times smaller than this fish and is eaten if (fishsize[j] >= i * 2 && fishsize[j] <= i *) {flag = FA
Lse
Break
} if (flag) count++;
else//Set flag to True to continue to determine if the next fish can enter the aquarium flag = true;
}return count;
public static void Main (string[] args) {//Enter the first behavior of the new fish size range minsize,maxsize (1≤minsize,maxsize≤1000), separated by a space.
Scanner s = new Scanner (system.in);
int minsize = S.nextint ();
int maxSize = S.nextint ();
Second act the fish inside already has the number n (1≤n≤50) int n = s.nextint ();
The third act already has the size of the fish Fishsize[i] (1≤fishsize[i]≤1000), separated by a space.
int fishsize[] = new Int[n];
for (int i = 0; i < n; i++) {Fishsize[i] = S.nextint ();
} nowcode_manyfish fish = new Nowcode_manyfish ();
int num = Fish.fishnum (minsize, MaxSize, fishsize);
SYSTEM.OUT.PRINTLN (num);
}
}