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

Problem 2 (only c++)
1 second
256 megabytes
everyone is afraid of something. someone is afraid of darkness, someone is afraid of heights, someone is afraid of public toilets (all of us are afraid of public toilets), someone is afraid of debts… there are many fears, but the greatest among all for unknown_user2019 is choosing a land for planting strawberries. unknown_user2019's land can be described as a matrix with n rows and m columns. some of the fields in the matrix are suitable for planting strawberries and some are not – weeds grow there. unknown_user2019 is looking for rectangular parts of the land that are completely filled with fields suitable for strawberry planting. those kinds of rectangles are called suitable rectangles. also, unknown_user2019 is interested in the potential value of all fields in the matrix. the potential value of each field in the matrix is defined as the number of suitable rectangles that contain that field. since unknown_user2019 has troubles facing his fears, he asks you to only calculate the sum of all the fields' potential values. input the first line contains two positive integers n and m (1 ≤ n, m ≤ 2 000), dimensions of the land. the next n lines contains m characters each, representing the landscape. each character can be either a ‘.’ (dot) which represents a field suitable for planting or a ‘#’ which represents weeds. output output the sum of all potential values of the matrix’s fields.
scoring in test cases worth 20% of the total points, it will hold that 1 ≤ n, m ≤ 10. in test cases worth additional 30% of the total points, it will hold that 1 ≤ n, m ≤ 300.
input
2 3 .#. .#
output
8
input
3 3
output
100
input
3 4 ..#. # #
output
40
clarification of the first sample test: the following matrix describes the potential values of the land’s fields. the sum of all potential values is 8.
2 0 1
3 2 0

👇
Открыть все ответы
Ответ:
Алёнка290613
Алёнка290613
29.11.2021
Будут вопросы - задавайте.

type a = array[0..999] of Integer;
var B, num: a; var N, k: integer; 
 
procedure SimpleNumber(B: a);
begin
    for var i := 0 to N-1 do begin
        for var j := 2 to 9 do begin
            if B[i] mod num[j] <> 0 then
                k += 1;
        end;
        if k = 8 then begin
             write('Есть простое число');
            break;
        end
        else if (k <> 8) and (i = N-1) then 
           write('Нет простых чисел');
        k := 0;
    end;
end;

begin
    for var i := 2 to 9 do begin
        num[i] := i;
    end;
    read(N);
    for var i := 0 to N-1 do 
        read(B[i]);
    SimpleNumber(B);
end.
4,4(56 оценок)
Ответ:
Бокс111
Бокс111
29.11.2021
Uses crt;
type TDMassiv = record
intMassiv : array of integer // Создали тип "динамический массив"
end;
var N, i, k : integer;
A : TDMassiv // Создали переменную A нового типа TDMassiv
Begin
clrscr;
randomize;
write('Vvedite kol-vo chisel');
readln(N);
SetLength(A, N) // Определяем, что массив А будет размера N элементов.
for i=1 to N do
begin
A[i] := random(10001); // Заполняем массив случайными числами [0..10000]
end;
k := 0; // k - это счетчик трехзначных чисел
for i=1 to N do
begin
if (A[i] >= 100) AND (A[i] <= 999) then k := k+1; // Считаем трехзначные числа
end;
if k := 0 then writeln ('HET') else writeln('Trehznachnyh chisel = ', k);
// Выводим посчитанное количество чисел на экран
END.
4,7(6 оценок)
Новые ответы от MOGZ: Информатика
logo
Вход Регистрация
Что ты хочешь узнать?
Спроси Mozg
Открыть лучший ответ