Cutting Recipes

What’s wrong in my code. I have tried all testcase but it gets failed every time on code chief. Please guide me that where I am doing wrong…

My program…

  #include <iostream>

   #include <bits/stdc++.h>

 using namespace std;

 int main()
 {
int testCase=0;
cin>>testCase;
int col=0;
int arr[100][100];
int arr1[100][100];
    for(int i=0;i<testCase;i++){
        int input_case=0;
        scanf("%d",&input_case);
        int minvalue=1000000;
        int count=0;
        for(int j=0;j<input_case;j++){
            scanf("%d",&arr[i][j]);

            if(minvalue>arr[i][j]){
                minvalue=arr[i][j];
            }
            if(arr[i][j]%minvalue==0){
                    arr1[i][j]=arr[i][j];
                arr[i][j]=arr[i][j]/minvalue;

                count++;
            }
            else{
                arr1[i][j]=arr[i][j];
            }
        }
        if(count==input_case){
            for(int j=0;j<input_case;j++){
                printf("%d ",arr[i][j]);
            }
        }
        else{
            for(int j=0;j<input_case;j++){
                printf("%d ",arr1[i][j]);
            }
        }

        printf("\n");




      }


     return 0;
 }

Contest Code:PRACTICE

Problem Code:RECIPE

Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile! :slight_smile:

2 Likes

done

1 Like

Thanks :slight_smile:

1 Like

Thanks, I never thought about larger test cases. :sweat_smile:

1 Like

I’m facing the same problem…
Even i tried these test cases…the answer and all spaces are correct acc. to me,
my code is a bit long but idk whats the error: its showing wrong answer

Please help…

#include
using namespace std;

int main() {
// your code goes here\

int t;
int n;
int arr[1000];
int n1,n2,count,small,i,j,cn;
cin>>t;
if(t<=100){
for(i=0;i<t;i++)
{
    cin>>n;
    if(n>=2&&n<=50){
    for(j=0;j<n;j++)
        cin>>(arr[j]);
        
          small=1000;
          cn=0;
   for(j=0;j<n;j++)
   {
       if(arr[j]>=2 & arr[j]<1000)
       cn=cn+1;
   }
    if(cn==n){
    for(j=0;j<n;j++)
    {
        if(arr[j]<small)
        small=arr[j];
    }
    count=0;
    for(j=0;j<n;j++)
    {
        if(arr[j]%small==0)
        count++;
    }
    if(count==n)
    {
        for(j=0;j<n;j++)
        arr[j]=arr[j]/small;
    }
    else{
        for(j=0;j<n;j++){
    cout<<(arr[j]);
    cout<<(" ");
    }
    break;
    }
    for(j=0;j<n;j++){
    cout<<(arr[j]);
    cout<<(" ");
    }
    cout<<endl;
    }
}
}
}
return 0;

}

Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile! :slight_smile:

Edit:

Your code also gives the wrong solution for the testcase above.

2 Likes