結果
問題 | No.2576 LCM Pattern |
ユーザー | Yoichiro Nishimura |
提出日時 | 2023-12-05 17:00:57 |
言語 | PHP (8.3.4) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 4,262 bytes |
コンパイル時間 | 196 ms |
コンパイル使用メモリ | 32,144 KB |
実行使用メモリ | 31,828 KB |
最終ジャッジ日時 | 2024-09-27 00:17:22 |
合計ジャッジ時間 | 1,817 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
31,828 KB |
testcase_01 | AC | 40 ms
31,532 KB |
testcase_02 | AC | 39 ms
31,476 KB |
testcase_03 | AC | 38 ms
31,340 KB |
testcase_04 | AC | 37 ms
31,480 KB |
testcase_05 | AC | 39 ms
31,168 KB |
testcase_06 | AC | 38 ms
31,232 KB |
testcase_07 | AC | 36 ms
31,648 KB |
testcase_08 | AC | 36 ms
31,636 KB |
testcase_09 | AC | 36 ms
31,244 KB |
testcase_10 | AC | 36 ms
31,244 KB |
testcase_11 | AC | 38 ms
31,168 KB |
testcase_12 | AC | 38 ms
31,516 KB |
testcase_13 | AC | 39 ms
31,472 KB |
testcase_14 | AC | 39 ms
31,588 KB |
testcase_15 | AC | 40 ms
31,360 KB |
testcase_16 | AC | 37 ms
31,412 KB |
testcase_17 | AC | 38 ms
31,316 KB |
testcase_18 | AC | 39 ms
31,464 KB |
testcase_19 | AC | 38 ms
31,644 KB |
testcase_20 | AC | 38 ms
31,772 KB |
testcase_21 | AC | 37 ms
31,412 KB |
testcase_22 | AC | 36 ms
31,440 KB |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php [$N, $M] = ints(); define("MOD", 998244353); $factors = factor($M); $p = 1; foreach($factors as $num => $count){ $p = mulm($p, subm(powerm($count+1, $N), powerm($count, $N))); } echo $p; //足し算 function addm($a, $b){ return ($a + $b) % MOD; } //引き算 function subm($a, $b){ return ($a + MOD - $b) % MOD; } //掛け算 function mulm($a, $b){ return (($a%MOD) * ($b%MOD)) % MOD; } //割り算 function divm($a, $b){ return mulm($a, powerm($b, MOD - 2)); } //累乗 function powerm($a, $b){ $a %= MOD; $ret = 1; while($b){ if($b&1)$ret=$ret*$a%MOD; $a = $a*$a%MOD; $b >>= 1; } return $ret; } function factor($M){ $map = []; $rootM = $M**0.5+1; for($j = 2; $j <= $rootM; $j++){ if($M%$j == 0){ if(!isset($map[$j]))$map[$j] = 0; $map[$j]++; $M/=$j; $rootM = $M**0.5+1; $j--; } } if($M>1){ if(!isset($map[$M]))$map[$M] = 0; $map[$M]++; } return $map; } function str(){return trim(fgets(STDIN));} function ints($n = false){ if($n===false){ $str = trim(fgets(STDIN));if($str == '')return []; return array_map('intval',explode(' ',$str)); }else{$ret = [];for($i = 0; $i < $n; $i++)foreach(array_map('intval',explode(' ',trim(fgets(STDIN)))) as $j => $v)$ret[$j][] = $v;return $ret;} } function int(){return intval(trim(fgets(STDIN)));} function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;} function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;} function isqrt($n):int{$res=intval(sqrt($n))+1;while($res*$res>$n)$res--;return $res;} function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;} function swap(&$a,&$b){$tmp=$a;$a=$b;$b=$tmp;} function o(...$val){ if(count($val)==1)$val=array_shift($val); echo debug_backtrace()[0]['line'].")"; if(is_array($val)){ if(count($val) == 0)echo "empty array\n"; elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n"; else{ echo "array:array\n"; if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n"; else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n"; } }else echo $val."\n"; } function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;} function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;} // 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap] function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];} function atsu1($array){$a=array_flip($array);$fuku=array_flip($a);sort($fuku);array_unshift($fuku,0);unset($fuku[0]);$atsu=array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];} function median($a){sort($a);$n=count($a);return $n%2?$a[($n-1)/2]:($a[$n/2-1]+$a[$n/2])/2;} function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;} function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);} function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;} function lcm($a, $b) {return $a / gcd($a, $b) * $b;} function loadTree($N = false){ if($N === false)$N = $GLOBALS['N']; return loadGraph($N, $N-1); } function loadGraph($N = false, $M = false, $both = true){ if($N === false)$N = $GLOBALS['N']; if($M === false)$M = $GLOBALS['M']; $G = array_fill(1, $N, []); for($i = 0; $i < $M; $i++){ $values = ints(); if(count($values) == 2){ list($a, $b) = $values; if($both == 0){ $G[$a][] = $b; }elseif($both == 1){ $G[$a][] = $b; $G[$b][] = $a; }else{ $G[$b][] = $a; } }else{ list($a, $b, $d) = $values; if($both == 0){ $G[$a][] = [$b, $d]; }elseif($both == 1){ $G[$a][] = [$b, $d]; $G[$b][] = [$a, $d]; }else{ $G[$b][] = [$a, $d]; } } } return $G; }