Загрузка данных



import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        double x = sc.nextDouble();
        double h = sc.nextDouble();
        double a = sc.nextDouble();

        List<Double> R = new ArrayList<>();

        for (int i = 1; i <= n; i++) {
            double value = 2.5 * Math.sin(a * x + i * i * h);
            R.add(value);
        }

        System.out.print("R={");
        for (int i = 0; i < R.size(); i++) {
            System.out.printf("%.3f", R.get(i));
            if (i < R.size() - 1) {
                System.out.print("; ");
            }
        }
        System.out.println("}");
    }
}




import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        double x = sc.nextDouble();
        double h = sc.nextDouble();
        double a = sc.nextDouble();

        List<Double> R = new ArrayList<>();

        for (int i = 1; i <= n; i++) {
            R.add(2.5 * Math.sin(a * x + i * i * h));
        }

        int minIndex = 0;

        for (int i = 1; i < R.size(); i++) {
            if (R.get(i) < R.get(minIndex)) {
                minIndex = i;
            }
        }

        int posIndex = -1;

        for (int i = 0; i < R.size(); i++) {
            if (R.get(i) > 0) {
                posIndex = i;
            }
        }

        if (posIndex == -1) {
            System.out.println("Нет положительного элемента");
        } else {
            int left = Math.min(minIndex, posIndex);
            int right = Math.max(minIndex, posIndex);

            for (int i = right - 1; i > left; i--) {
                if (R.get(i) < 0) {
                    R.remove(i);
                }
            }
        }

        System.out.print("R={");
        for (int i = 0; i < R.size(); i++) {
            System.out.printf("%.3f", R.get(i));
            if (i < R.size() - 1) {
                System.out.print("; ");
            }
        }
        System.out.println("}");
    }
}



import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        double x = sc.nextDouble();
        double h = sc.nextDouble();
        double a = sc.nextDouble();

        List<Double> R = new ArrayList<>();

        for (int i = 1; i <= n; i++) {
            R.add(2.5 * Math.sin(a * x + i * i * h));
        }

        int minIndex = 0;

        for (int i = 1; i < R.size(); i++) {
            if (R.get(i) < R.get(minIndex)) {
                minIndex = i;
            }
        }

        int posIndex = -1;

        for (int i = 0; i < R.size(); i++) {
            if (R.get(i) > 0) {
                posIndex = i;
            }
        }

        if (posIndex != -1) {
            int left = Math.min(minIndex, posIndex);
            int right = Math.max(minIndex, posIndex);

            for (int i = right - 1; i > left; i--) {
                if (R.get(i) < 0) {
                    R.remove(i);
                }
            }
        }

        double sum = 0;
        int count = 0;
        boolean found = false;

        for (int i = 0; i < R.size(); i++) {
            if (R.get(i) < 0) {
                found = true;
                break;
            }

            sum += R.get(i);
            count++;
        }

        if (!found || count == 0) {
            System.out.println("Нет среднего значения");
        } else {
            double sr = sum / count;
            System.out.printf("Sr=%.3f%n", sr);
        }
    }
}