М
Молодежь
К
Компьютеры-и-электроника
Д
Дом-и-сад
С
Стиль-и-уход-за-собой
П
Праздники-и-традиции
Т
Транспорт
П
Путешествия
С
Семейная-жизнь
Ф
Философия-и-религия
Б
Без категории
М
Мир-работы
Х
Хобби-и-рукоделие
И
Искусство-и-развлечения
В
Взаимоотношения
З
Здоровье
К
Кулинария-и-гостеприимство
Ф
Финансы-и-бизнес
П
Питомцы-и-животные
О
Образование
О
Образование-и-коммуникации

Вводятся 5 чисел: a, b, c, d и e. найдите все целые решения уравнения ( ax3 + bx2 + cx + d ) / ( x - e ) = 0 на отрезке [0,1000] и выведите их количество. примеры входные данные 2 4 9 1 5 выходные данные 0

👇
Ответ:
maririz405
maririz405
15.01.2023
//Когда Глеб расстроился
//Pascal ABC.NET 3.1 сборка 1256

Var
 a,b,c,d,e:real;
 
procedure cube(a,b,c,d,e:real);
Var
 p,q,delta,phi,i:real;
 y:array[1..3] of real;
begin
p:=(3*a*c-sqr(b))/(3*sqr(a));
q:=(2*power(b,3)-9*a*b*c+27*sqr(a)*d)/(27*power(a,3));
delta:=power(q/2,2)+power(p/3,3);
if delta<0 then
 begin
  if q<0 then
   phi:=arctan(sqrt(-delta)/(-q/2));
  if q>0 then
   phi:=arctan(sqrt(-delta)/(-q/2))+pi;
  if q=0 then
   phi:=pi/2;
  y[1]:=2*sqrt(-p/3)*cos(phi/3);
  y[2]:=2*sqrt(-p/3)*cos(phi/3+(2*pi)/3);
  y[3]:=2*sqrt(-p/3)*cos(phi/3+(4*pi)/3);
  var x:=seq(y[1]-b/(3*a),y[2]-b/(3*a),y[3]-b/(3*a));
  write(x.where(x -> x<>e).where(x -> frac(x)=0).where(x -> x>=0).Where(x -> x<=1000).Distinct.Count);
 end;
if delta>0 then
 begin
  var arsom:=range(0,1000).Where(x->(a*power(x,3)+b*x*x+c*x+d)/(x-e)=0);
  write(arsom.Count);
  {Мы не виноваты, Паскаль не может в комплексные числа}
 end;
if delta=0 then
 begin
  y[1]:=2*power(-q/2,1/3);
  y[2]:=-power(-q/2,1/3);
  var x:=seq(y[1]-b/(3*a),y[2]-b/(3*a));
  write(x.where(x -> x<>e).where(x -> frac(x)=0).where(x -> x>=0).Where(x -> x<=1000).Distinct.Count);
 end;
end;

procedure square(a,b,c,e:real);
Var
 d:real;
begin
d:=sqr(b)-4*a*c;
if d<0 then writeln('0');
if d>0 then
 begin
  var x:=arr((-b+sqrt(d))/(2*a),(-b-sqrt(d))/(2*a));
  write(x.where(x -> x<>e).where(x -> frac(x)=0).where(x -> x>=0).Where(x -> x<=1000).Distinct.Count);
 end;
if d=0 then
 begin
  var x:=arr(-b/(2*a));
  write(x.where(x -> x<>e).where(x -> frac(x)=0).where(x -> x>=0).Where(x -> x<=1000).Distinct.Count);
 end;
end;

procedure common(a,b,e:real);
begin
 var x:=arr(-b/a);
 write(x.where(x -> x<>e).where(x -> frac(x)=0).where(x -> x>=0).Where(x -> x<=1000).Distinct.Count);
end;

procedure awfulvar(e:real);
begin
 if (e>=0) and (e<=1000) then writeln('1000') else writeln('1001');
end;

procedure otherawfulvar(e:real);
begin
 if e<>0 then writeln('1') else writeln('0');
end;

begin
read(a,b,c,d,e);
if (a<>0) and (b<>0) then cube(a,b,c,d,e);
if (a=0) and (b<>0) then square(b,c,d,e);
if (a=0) and (b=0) and (c<>0) and (d<>0) then common(c,d,e);
if (a=0) and (b=0) and (c=0) and (d=0) then awfulvar(e);
if (a=0) and (b=0) and (c<>0) and (d=0) then otherawfulvar(e);
if (a=0) and (b=0) and (c=0) and (d<>0) then writeln('0');
end.

Пример ввода:
1
1
1
1
1
Пример вывода:
0
4,7(4 оценок)
Ответ:
лолл18
лолл18
15.01.2023
//Pascal

const
  LOWER = 0; //Нижняя граница
  UPPER = 1000; //Верхняя граница

var
  a, b, c, d, e, x, cnt: integer;

begin
  read(a, b, c, d, e);
  for x := LOWER to UPPER do
    if (a*x*x*x + b*x*x + c*x + d = 0) and (x <> e) then
      inc(cnt);
  writeln(cnt);
end.

Пример ввода:
3
4
2
0
1

Пример вывода:
1
4,8(44 оценок)
Открыть все ответы
Ответ:
af1045017202
af1045017202
15.01.2023
В C++
#include <iostream>
#include <iomanip>
#include <ctime>
int main()
{
    using namespace std;

    const int N = 5;
    const int M = 6;

    int A[N][M];

    //Как-нибудь заполняем массив
    srand(time(0));
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < M; ++j)
            A[i][j] = rand() % (N * M) + 1;
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < M; ++j)
            cout << setw(4) << A[i][j];
        cout << endl;
    }

   
    //Подсчитываем сумму всех элементов массива
    int sum = 0;

    for (int i = 0; i < N; ++i)
        for (int j = 0; j < M; ++j)
            sum += A[i][j];

    //Вычитаем из полученной суммы повторяющиеся элементы
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < M; ++j)
        {
            bool flag = false;
            for (int i1 = 0; i1 < N; ++i1)
            {
                for (int j1 = 0; j1 < M; ++j1)
                    if (!(i == i1 && j == j1))
                        if (A[i][j] == A[i1][j1])
                        {
                            sum -= A[i][j];
                            flag = true;
                            break;
                        }
                if (flag)
                    break;
            }
        }

    cout << "Sum of different: " << sum << endl;

    return 0;
}
4,6(83 оценок)
Ответ:
Nastias1603
Nastias1603
15.01.2023
В C++
#include <iostream>
#include <iomanip>
#include <ctime>
int main()
{
    using namespace std;

    const int N = 5;
    const int M = 5;

    //Создаём массив и как-нибудь заполняем
    int A[N][M];
    srand(time(0));
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < M; ++j)
            A[i][j] = rand() % (N * M) + 1;
   
    //Выводим его на экран
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < M; ++j)
            cout << setw(4) << A[i][j];
        cout << endl;
    }

    //Меняем местами 2ю и 3ю строки
    int temp = 0;
    for (int j = 0; j < M; ++j)
    {
        temp = A[1][j];
        A[1][j] = A[2][j];
        A[2][j] = temp;
    }

    //Выводим полученный массив на экран
    cout << "\n\n";
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < M; ++j)
            cout << setw(4) << A[i][j];
        cout << endl;
    }

    return 0;
}
4,5(45 оценок)
Новые ответы от MOGZ: Информатика
logo
Вход Регистрация
Что ты хочешь узнать?
Спроси Mozg
Открыть лучший ответ