Safe Division

Safe Division

Easy PHP PHP Error Handling 37 views
Explanation Complexity

Problem Statement

Print a/b as integer. If b is 0, print DIVIDE_BY_ZERO.

Input Format

One line: a b.

Output Format

Quotient or DIVIDE_BY_ZERO.

Example

10 0
DIVIDE_BY_ZERO

Constraints

|a|,|b|

Input / Output Format

Input Format
One line: a b.
Output Format
Quotient or DIVIDE_BY_ZERO.
Constraints
|a|,|b|

Examples

Input:
10 0
Output:
DIVIDE_BY_ZERO

Example Solution (Public)

PHP
<?php
$inputText=trim(stream_get_contents(STDIN));
if($inputText==='') exit;
[$a,$b]=array_map('intval',preg_split('/\\s+/', $inputText));
if($b===0) echo 'DIVIDE_BY_ZERO';
else echo intdiv($a,$b);
?>

Official Solution Code

<?php
$inputText=trim(stream_get_contents(STDIN));
if($inputText==='') exit;
[$a,$b]=array_map('intval',preg_split('/\\s+/', $inputText));
if($b===0) echo 'DIVIDE_BY_ZERO';
else echo intdiv($a,$b);
?>
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.