-
Well, let's break it down.
The upper bound of the time complexity of decomposing a number n into prime factors is o(n. According to the performance of the current computer, if you want to solve it within the time limit, n is probably less than one million, so that the maximum number n can only be 10 14. And this range is perfectly manageable with int64.
If int64 can't be processed, then this number cannot be solved within the time limit even with high precision.
-
If your n is large enough, then its factor sum must be much larger than his, so it will be out of bounds (maxlongint=21474843647) ......So your n isn't big enough, so use the upstairs one to solve ......
-
Description: Keyboard input of a positive integer (1 example input:
Sample output: include
int main()
if(s==1)break;
if(s!=1)
elseelse i++;
printf("*%ld",n);}
return 0;}
-
var n:longint;
procedure zys(x:longint);Decomposition factor process.
var i,k:longint;
begink:=1;
while x>1 do
begini:=0;inc(k);
while x mod k=0 do
begininc(i);
x:=x div k;
end;if i>1 then print the factor.
if x=1 then write(k,'^',i)
else write(k,'^',i,'*')
else if i=1 then
if x=1 then write(k)
else write(k,'*');
end;end;
begin main program.
read(n);
zys(n);Invoke the procedure.
end.
-
I'll give you a problem I did before, and it worked.
Find the factorization of the number between x y.
program yinshu;
vara,b,n,c,x,y:integer;
beginreadln(x);
readln(y);
for a:=x to y do
beginb:=2;
n:=0;c:=a;
write(a,'=');
repeat
if c mod b=0
thenbegin
c:=c div b;
if n=0
thenwrite(b)
elsewrite('*',b);
n:=1;endelse
b:=b+1;
until c=1;
writeln;
end;readln;
end.
-
1. Add a string s to store the output result.
2,write(i,'*');Change to s:=s+str(i)+'*';
3,Finally, output: write(copy(s, 1, length(s)-1));
-
You output one first.
if n mod i==0 write(i);
b:=n div i;
while n>=i do begin
while n mod i ==0 do beginwrite(‘*i);
n:=n div i;
end;It's been a long time since I've written pascal, are you sure the judgment is =not==?
Of course there is, both grammatically and functionally, but in reality ......The application of C is much more powerful than Pascal, if you want to learn it it is recommended that you want to learn Pascal, and then learn C
If you want, leave an email and I'll send it to you.
The system will not treat those two as the same array, it should be defined by type, and then both arrays should be defined as type.
I don't know what the map looks like, but what about you. >>>More
The Pascal compilation system is a system software. Pascal is the first structured programming language with rigorous syntax, clear hierarchy, easy to write and readable programs. Pascal language is widely used in various software, and the program is divided into name (self-proposed after program), setting (defined after var), start (begin), program (body), read (read read ln), and end (end), with strong structural hierarchy, rigorous and tight. >>>More