Advertisement
CyberN00b

Задачи с делителями

Oct 30th, 2020 (edited)
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.11 KB | None | 0 0
  1. program prog;
  2. var
  3.   a, b, c, i, j, count, n:longint;
  4.   f : boolean;
  5. begin
  6.   readln(a);
  7.  
  8.   // на ходим все делители числа а
  9.  
  10.   for i := 1 to round(sqrt(a)) do
  11.     if (a mod i = 0) then
  12.       writeln(i,' ', a div i);
  13.  
  14.   //находим кол-во делителей
  15.  
  16.   count := 0;
  17.   for i := 1 to round(sqrt(a)) - 1 do
  18.     if (a mod i = 0) then
  19.       count := count + 2;
  20.   if (round(sqrt(i)) * round(sqrt(i)) = i) then
  21.     count := count + 1;
  22.   writeln(count);
  23.  
  24.   //числа с N делителями на отрезке
  25.  
  26.   read(a, b, n);
  27.   for i := a to b do begin
  28.     count := 0;
  29.     for j := 1 to round(sqrt(i)) - 1 do
  30.       if (i mod j = 0) then
  31.         count := count + 2;
  32.     if (round(sqrt(i)) * round(sqrt(i)) = i) then
  33.       count := count + 1;
  34.     if (count = n) then
  35.       writeln(i);
  36.   end;
  37.  
  38.   //проверяем простое ли число
  39.  
  40.   readln(a);
  41.   f := true;
  42.   for i := 2 to round(sqrt(a)) do
  43.     if (a mod i = 0) then begin
  44.       f := false;
  45.       break;
  46.     end;
  47.   if (f) then
  48.     writeln('YES')
  49.   else
  50.     writeln('NO');
  51. end.
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement