MARCHA4: Why am I getting wa

import java.math.BigInteger;
class Example

			System.out.println("Enter the number of test cases");
			BufferedReader br=new BufferedReader(new InputStreamReader(;
			int testCase=Integer.parseInt(br.readLine());
			for(int i=1;i<=testCase;i++)
				System.out.println("Enter the number");
				BufferedReader b=new BufferedReader(new InputStreamReader(;
				BigInteger bi1=new BigInteger(b.readLine());
				System.out.println("Enter the number of digits required");
				BufferedReader b1=new BufferedReader(new InputStreamReader(;
				int k=Integer.parseInt(b1.readLine());
				double j=bi1.doubleValue();
				BigInteger bi3=bi1;
				for(double m=1;m<j;m++)
				String sNum=bi3.toString();
				String beginDigits=sNum.substring(0, k);
				String endDigits=sNum.substring(sNum.length()-k, sNum.length());
				System.out.println(beginDigits+" "+endDigits);
		catch(Exception e)
			e.printStackTrace();// TODO Auto-generated constructor stub

	 * @param args
	public static void main(String[] args) 
		new Example();// TODO Auto-generated method stub



Problem statement is here.

I am new here… please tell me where am i going wrong…

You are new here and you starts with medium problems? Try easy ones, just to realize how to server works. I didn’t test your code completely, but you have to read FAQ, especially section How does Codechef test whether my solution is correct or not, first :wink:

If your program starts by printing ‘Enter the number’ and the problem does not tell you to do so, then since this is not part of the correct output, you will be never be judged correct regardless of what the rest of your program does.

Hi CodeChef,

I am jimit and My username is “jimit_it”. I tried to solve below problems and I have written cod in PHP. Can you tell me why it is giving me wrong answer. I want to know where I am being wrong or what I am doing wrong.

  1. Problem:

My Submitted Code for above problem in PHP as below.

//Suppose below are my posted array

$nTimeMul = array(4,9);
$nToAppear = array(2,3);
function getDezireOutput($nTimeMul = array(), $nToAppear = array()) {
$i = 0;
foreach ($nTimeMul as $num) {
$tempNum = 1;
for ($t=0; $t < $num; $t++) {

$tempNum = $tempNum * $num;
echo substr ($tempNum, 0, $nToAppear[$i]).' '.substr ($tempNum, -$nToAppear[$i]).'

getDezireOutput ($nTimeMul, $nToAppear);

Please have look into above problem and let me know the problems with above code so, I can figure it out.

Waiting for your reply.

Jimit Shah

Hi CodeChef,

Can any one tell me why I am getting wrong answer for problem ? I have written code in PHP.
I have tested below code command line too. please let me know what is the problem with below code for mentioned problem.

    $stdin = fopen('php://stdin', 'r');
    //echo 'Please enter num. of test cases & num of plates:';
    $testcaseCnt = fgets($stdin);
    $numOfPlates = fgets($stdin);
    $i = 0;
    while ($i < $testcaseCnt) {
    $inputArr = array();
    $j = 0;
    //echo 'Please enter plate names:';
    while ($j < $numOfPlates) {
    $input = fgets($stdin);
    $inputArr[$j] = $input;
    if (count($inputArr) > 0) {
    $result = opendDoor($inputArr);
    echo $result;
    } else {
    echo "The door cannot be opened. \n\n";
    function opendDoor($inputArr)
    $totalPlate = count($inputArr);
    $plateArr = array();
    $plateArr[] = array_shift($inputArr);
    $remainArr = $inputArr;
    $i = 0;
    foreach ($inputArr as $input) {
    $tempName = trim(end($plateArr));
    $lastChar = substr($tempName, -1);
    foreach ($remainArr as $iKey => $iVal) {
    $firstChar = substr(trim($iVal), 0, 1);
    if ($lastChar == $firstChar) {
    $plateArr[] = $iVal;
    if ($totalPlate == count($plateArr)) {
    return "Ordering is possible.\n\n";
    } else {
    return "The door cannot be opened.\n\n";

Thanks for your support code, it is very well

truy?n ch??ng , t?ng traffic, t?ng l??ng truy c?p website, d?ch v? seo, truy?n ki?m hi?p, ??c truy?n online , may do tieu duong, máy ?o huy?t áp, Th?c ph?m ch?c n?ng, s?a ong chúa, thu?c b? t?ng h?p, thu?c gi?m cân, nhau thai c?u, Gi??ng y t?