Pascal is programmed to input n and m, output n to the m power, and the answer will not exceed the l

Updated on technology 2024-04-15
11 answers
  1. Anonymous users2024-02-07

    varn,m,i:integer;

    t:int64;

    s:longint;

    x:boolean

    beginx:=false;

    while x=false do

    beginwrite('bottom number (n):');

    readln(n);

    write('exponent (m):');

    readln(m);

    t:=1;for i:=1 to m do t:=t*n;Powered by.

    if t > 2147483648 then to determine whether the result is outside the longint range.

    beginx:=false;

    writeln('error!');

    endelse begin

    x:=true;

    s:=t;write(n,'^',m,'=',s);

    end;end.

  2. Anonymous users2024-02-06

    First of all, the landlords trust me to have a program that is shorter and better than theirs:

    1:program exam;var i,x:integer;beginx:

    1;for i:=1 to 99 dox:=x*99;writeln(x mod 1000);:

    This question is more classic, and my method is the simplest in history, referred to as the sieve method.

    program zhishu;

    var x,n: longint;

    var j:boolean;

    beginwhile not eof do

    beginreadln(n);

    if (n=0) or (n=1) then writeln('n','o') else

    beginx:=2;

    j:=true;

    for x:=2 to round(sqrt(n)) doif n mod x = 0 then j:=false;

    if j=true then writeln('yes') else writeln ('no');

    end;end;

    end.The watchtower lord adopted.

    Troublesome. Adopt. ·.

  3. Anonymous users2024-02-05

    You are chenquxin, this question is too big data, with high precision. Program: Program P1036; var i,j,k,m,n:

    longint; a,b,c:array[1..25] of longint; x,y,l:

    int64; begin readln(x,y); if x mod 2=1 then inc(x); if y mod 2=1 then dec(y); if x>y then writeln('0') else begin l:=(y-x) div 2+1;x:=x+y;y:

    l;m:=0;n:=0; if x mod 2=0 then x:

    x div 2 else y:=y div 2; repeat inc(m); a[m]:=x mod 10;x:

    x div 10; until x=0; repeat inc(n); b[n]:=y mod 10;y:=y div 10; until y=0; for i:

    1 to m do for j:=1 to n do c[i+j-1]:=c[i+j-1]+a[i]*b[j]; for j:

    1 to n+m do begin c[j+1]:=c[j+1]+c[j] div 10; c[j]:=c[j] mod 10; end; l:

    m+n; while c[l]=0 do dec(l); for i:=l downto 1 do write(c[i]);end; end.

  4. Anonymous users2024-02-04

    The reason for the upstairs error is that the longint is only 10 digits, which is not enough range. You try to use real, and write write(s,0,0) when output; If the number is too large and the scientific notation is output, the only way to do this is to take some time to write high-precision.

  5. Anonymous users2024-02-03

    Hello landlord.

    Lucky to see your problem.

    I can't help you enough!

    It may be that the question you are asking is a bit professional. Or someone else hasn't encountered or touched your problem, so they can't help you. It is recommended that you go to the relevant forum for help, where there are usually more people and more enthusiastic, and may be able to help you solve the problem quickly.

    Good luck. Finally, I wish you a happy, healthy and happy family every day!

  6. Anonymous users2024-02-02

    Pure simulation on the line,2013julyxx hit the program should be right,But what is your n range?,There is another situation that is-no matter how much m is,Can't meet the requirements,What is the output at this time?

  7. Anonymous users2024-02-01

    var a:array [1..1000000] of longint;b:array [1..1000000] of boolean;

    i,j,n,m,s:longint;

    beginreadln(n,m);for i:=2 to m do begin a[i]:=i;b[i]:=true;end;i:=1;

    repeat

    i:=i+1;if b[i]=true then for j:=2 to m div i do b[j*i]:=false;

    until i=m;

    for i:=2 to m do if (b[i]=true)and(a[i]>=n) then s:=s+1;writeln(s);

    end.May I ask Li Zhe, did you do it on Fenghua? In other words, if it is, it is right to grind potatoes.

    82872 dengke 1153 accepted 5416k 61ms pascal 2009-11-06 14:09:18

  8. Anonymous users2024-01-31

    You can only use the Miller Rabin prime number test (Lead Lu remembers seeing it in "The Art of Sakura Fantasy Algorithm").

    According to a large number of statistics, if a (n-1)mod n=1 is satisfied, then the probability of spinal combustion is prime.

    There's a C++ here, but the idea should be the same.

  9. Anonymous users2024-01-30

    Does it also time out to do it with the screening method?

  10. Anonymous users2024-01-29

    You can also add some methods to the push function to execute, for example:

    view plaincopy

    var visitor_id;

    function()

  11. Anonymous users2024-01-28

    After recursion bz:=true, bz may be assigned to false again in later results, so an error will occur. The modifications are as follows, if you don't understand, you can send a private message or ask.

    vara:array[1..10] of longint;

    b:array[1..10] of longint;

    n,m,i:longint;

    procedure sum(n,m:longint);

    beginif m=0 then begin

    writeln('yes');

    halt;endelse

    beginif n=1 then exit elsebegin

    sum(n-1,m-a[n]);

    sum(n-1,m);

    end;end;

    end;begin

    readln(n);

    for i:=1 to n do

    read(a[i]);

    readln(m);

    sum(n,m);

    writeln('no');

    end.

Related questions
5 answers2024-04-15

Just use an array.

var a:array[1..1000]of longint; >>>More

19 answers2024-04-15

Choose the graphics card first,Most graphics cards are connected to the display with dual interface design24-pin digital signal interface and 15-pin analog signal interface,There is also an HDMI output input interface,When you connect to the current display,You can buy an adapter as needed。

12 answers2024-04-15

I don't understand what you mean by this particular case, if you mean an invalid input, such as entering a letter, then in int a = ; >>>More

5 answers2024-04-15

MCU, all IO ports can be used as input and output, but not at the same time >>>More

3 answers2024-04-15

The size of the array is defined when it is defined. I understand what you mean: first enter the number of students n to be counted, which is also to define an array of size n, a lazy way is that you pre-define a large array, far beyond the limit of what you can use, for example, you may count the results of 100 people, you can pre-define an array of size 1000 to store the grades, so that you can use a for loop. >>>More