@ 2014-05-17T13:13:19Z <?
class BigAndSmallStep
{
public $f;
public $b;
public $n;
public $a;
public $L1 = array();
public $L2 = array();
public $findStr;
public $result;
public function __construct ($f, $b, $n)
{
$this->f = intval($f);
$this->b = intval($b);
$this->n = intval($n);
$this->a = self::countA($this->n);
}
function countA($n)
{
return ceil(sqrt($n));
}
function countL1()
{
$c = $this->a-1;
$i = 0;
while ( $i <= $c) {
$heig = $i * $this->a;
//echo $heig."<br/>";
$this->L1[$i] = array($i, $heig, self::countResL1($heig));
$i++;
}
return true;
}
function countL2()
{
$c = $this->a;
$i = 0;
while ( $i <= $c) {
$this->L2[$i] = array($i, self::countResL2($i));
$i++;
}
return true;
}
function mod($x, $y)
{
return fmod($x, $y);
}
function countResL1($heig)
{
$number = pow($this->f, $heig);
//echo $number."<br>";
return self::mod( $number, $this->n);
}
function countResL2($heig)
{
$number = $this->b * (pow($this->f, $heig));
//echo $number."<br>";
return self::mod( $number, $this->n);
}
function searchRes()
{
$c = count($this->L1)-1;
$i = 0;
while ( $i<= $c) {
$ser = $this->L1[$i][2];
$res = self::searchValueInL2($ser);
if($res !== false)
{
return $this->findStr = $i."_".$res;
}
$i++;
}
return false;
}
function searchValueInL2($value)
{
$c = count($this->L2)-1;
$i = 0;
while ( $i <= $c) {
if($this->L2[$i][1] == $value)
{
return $i;
}
$i++;
}
return false;
}
function finalResult()
{
$elem = split("_", $this->findStr);
$first = self::mod($this->b, $this->n);
$heig = $this->L1[$elem[0]][1] - $this->L2[$elem[1]][0];
$this->result = ceil(self:: mod ( pow($this->f,$heig), $first)) ;
}
function showRiv()
{
$elem = split("_", $this->findStr);
$f_h = ($this->L2[$elem[1]][0] != 1) ? $this->L2[$elem[1]][0] : ' ';
echo " ".$this->b." * ".$this->f. "<sup><small>".$f_h."</small></sup> = ". $this->f."<sup><small>".$this->L1[$elem[0]][1]. "</small></sup> mod ". $this->n;
}
function getResult()
{
return $this->result;
}
}
$alg = new BigAndSmallStep(2, 11, 13);
if ( ($alg->countL1() != false) && ($alg->countL2() !=false )){
$alg->searchRes();
$alg->finalResult();
$alg->showRiv();
echo "<br/> Result x = ".$alg->getResult();
}
else
echo "Ошибочка =(";
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 4.3.0 - 4.3.11 , 4.4.0 - 4.4.9 , 5.0.0 - 5.0.5 , 5.1.0 - 5.1.6 , 5.2.0 - 5.2.17 , 5.3.0 - 5.3.29 , 7.2.29 - 7.2.33 , 7.3.12 - 7.3.31 , 7.4.0 - 7.4.25 , 7.4.27 - 7.4.32 , 8.0.0 - 8.0.12 , 8.0.14 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 <?
class BigAndSmallStep
{
public $f;
public $b;
public $n;
public $a;
public $L1 = array();
public $L2 = array();
public $findStr;
public $result;
public function __construct ($f, $b, $n)
{
$this->f = intval($f);
$this->b = intval($b);
$this->n = intval($n);
$this->a = self::countA($this->n);
}
function countA($n)
{
return ceil(sqrt($n));
}
function countL1()
{
$c = $this->a-1;
$i = 0;
while ( $i <= $c) {
$heig = $i * $this->a;
//echo $heig."<br/>";
$this->L1[$i] = array($i, $heig, self::countResL1($heig));
$i++;
}
return true;
}
function countL2()
{
$c = $this->a;
$i = 0;
while ( $i <= $c) {
$this->L2[$i] = array($i, self::countResL2($i));
$i++;
}
return true;
}
function mod($x, $y)
{
return fmod($x, $y);
}
function countResL1($heig)
{
$number = pow($this->f, $heig);
//echo $number."<br>";
return self::mod( $number, $this->n);
}
function countResL2($heig)
{
$number = $this->b * (pow($this->f, $heig));
//echo $number."<br>";
return self::mod( $number, $this->n);
}
function searchRes()
{
$c = count($this->L1)-1;
$i = 0;
while ( $i<= $c) {
$ser = $this->L1[$i][2];
$res = self::searchValueInL2($ser);
if($res !== false)
{
return $this->findStr = $i."_".$res;
}
$i++;
}
return false;
}
function searchValueInL2($value)
{
$c = count($this->L2)-1;
$i = 0;
while ( $i <= $c) {
if($this->L2[$i][1] == $value)
{
return $i;
}
$i++;
}
return false;
}
function finalResult()
{
$elem = split("_", $this->findStr);
$first = self::mod($this->b, $this->n);
$heig = $this->L1[$elem[0]][1] - $this->L2[$elem[1]][0];
$this->result = ceil(self:: mod ( pow($this->f,$heig), $first)) ;
}
function showRiv()
{
$elem = split("_", $this->findStr);
$f_h = ($this->L2[$elem[1]][0] != 1) ? $this->L2[$elem[1]][0] : ' ';
echo " ".$this->b." * ".$this->f. "<sup><small>".$f_h."</small></sup> = ". $this->f."<sup><small>".$this->L1[$elem[0]][1]. "</small></sup> mod ". $this->n;
}
function getResult()
{
return $this->result;
}
}
$alg = new BigAndSmallStep(2, 11, 13);
if ( ($alg->countL1() != false) && ($alg->countL2() !=false )){
$alg->searchRes();
$alg->finalResult();
$alg->showRiv();
echo "<br/> Result x = ".$alg->getResult();
}
else
echo "Ошибочка =(";
?> Output for 7.0.0 - 7.0.20 , 7.1.0 - 7.1.20 , 7.2.0 - 7.2.6 , 7.3.32 - 7.3.33 , 7.4.26 , 7.4.33 , 8.0.13 Fatal error: Uncaught Error: Call to undefined function split() in /in/nVoe1:111
Stack trace:
#0 /in/nVoe1(136): BigAndSmallStep->finalResult()
#1 {main}
thrown in /in/nVoe1 on line 111
Process exited with code 255 . Output for 5.5.0 - 5.5.35 , 5.6.0 - 5.6.28 Deprecated: Function split() is deprecated in /in/nVoe1 on line 111
Deprecated: Function split() is deprecated in /in/nVoe1 on line 120
11 * 2<sup><small> </small></sup> = 2<sup><small>8</small></sup> mod 13<br/> Result x = 7 Output for 5.4.0 - 5.4.45 11 * 2<sup><small> </small></sup> = 2<sup><small>8</small></sup> mod 13<br/> Result x = 7 preferences:dark mode live preview
270.77 ms | 402 KiB | 346 Q