Pagini recente » Cod sursa (job #231897) | Cod sursa (job #2919599) | Cod sursa (job #2865070) | Cod sursa (job #2228184) | Cod sursa (job #589829)
Cod sursa(job #589829)
program ssnd1 ;
const FIN = 'ssnd.in' ;
FOU = 'ssnd.out' ;
MAX = 1000005 ;
MDD = 9973 ;
var P : array [ 0 .. MAX ] of longint ;
T : longint ;
V : array [ 0.. 1 shl 17 ] of byte ;
N : int64 ;
procedure prec ;
var i, j : longint ;
begin
inc ( P[0] ) ; P[ P[0] ] := 2 ;
i := 1 ;
while ( i * i shl 1 ) + ( i shl 1 ) <= MAX do
begin
if ( V[i shr 3] and ( 1 shl ( i and 7 ) ) ) = 0 then
begin
j := ( i * i shl 1 ) + ( i shl 1 ) ;
while ( j shl 1 ) + 1 <= MAX do
begin
V[j shr 3] := V[j shr 3] or ( 1 shl ( j and 7 ) ) ;
inc ( j, ( i shl 1 ) + 1 ) ;
end ;
end ;
inc ( i ) ;
end ;
i := 1 ;
while ( i shl 1 ) + 1 <= MAX do
begin
if ( V[i shr 3] and ( 1 shl ( i and 7 ) ) ) = 0 then
begin
inc ( P[0] ) ;
P[ P[0] ] := ( i shl 1 ) + 1 ;
end ;
inc ( i ) ;
end ;
end ;
function pow ( N : longint ; P : longint ) : longint ;
var i, sol : longint ;
begin
sol := 1 ; N := N mod MDD ; i := 0 ;
while ( 1 shl i ) <= P do
begin
if ( ( 1 shl i ) and P ) > 0 then
begin
sol := sol * N ;
sol := sol mod MDD ;
end ;
N := N * N ; N := N mod MDD ;
inc ( i ) ;
end ;
pow := sol ;
end ;
procedure ssnd ;
var i, nr, sum, pp : longint ;
begin
readln ( N ) ;
nr := 1 ; sum := 1 ; i := 1 ;
while ( int64 ( P[i] ) * int64 ( P[i] ) <= N ) and ( i <= P[0] ) do
begin
if ( N mod P[i] = 0 ) then
begin
pp := 0 ;
while ( N mod P[i] ) = 0 do
begin
inc ( pp ) ;
N := N div P[i] ;
end ;
nr := nr * ( pp + 1 ) ;
sum := sum * ( pow ( P[i], pp + 1 ) - 1 ); sum := sum mod MDD ;
sum := sum * ( pow ( P[i] - 1, MDD - 2 ) ); sum := sum mod MDD ;
end ;
inc ( i ) ;
end ;
if ( N > 1 ) then
begin
nr := nr shl 1 ;
sum := sum * ( ( N + 1 ) mod MDD ); sum := sum mod MDD ;
end ;
writeln ( nr, ' ', sum ) ;
end ;
begin
assign ( input, FIN ) ; reset ( input ) ;
assign ( output, FOU ) ; rewrite ( output ) ;
prec ; readln ( T ) ;
while ( T > 0 ) do
begin
ssnd ;
dec ( T ) ;
end ;
close ( input ) ; close ( output ) ;
end .