You are not logged in. Please login at www.codechef.com to post your questions!

×

# CUTTING RECIPES

 0 Problem: http://www.codechef.com/problems/RECIPE difficulty:easy Hello, I have tried many times but i am unable to point out any errors (logical) errors in my code.I am getting a wrong answer for this code.It works fine on my machine giving correct output.Can anybody help me out. I have found the two smallest numbers(min1 and min2) and then their gcd. If the gcd is not 1 then i am checking whether their gcd divides all the remaining nos without leaving behind any remainder.If it is 1 i simply print all nos. If so then i divide all the numbers by the gcd and output the result. Else i simply output all the numbers. #include  using namespace std; int main() { int t,n,i,min1,min2,arr[50]; cin>>t; while(t--) {  cin>>n; i=0; //since max value of any no. can be 1000 min1=min2=1001; //min1>arr[i]; if(arr[i]

One Answer:
 0 @s_enterpreneur Consider the array : 8 16 22 Minimum(m1)=8 and second minimum(m2)=16. gcd(m1,m2)=gcd(8,16)=8 which is non-zero. =>your output is 1 2 2 (note that 22/8 =2) However required output is 4 8 11. Hope you understand. answered 04 Aug '14, 02:35 333●2●3●9 accept rate: 20%
 toggle preview community wiki:
Preview

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• link:[text](http://url.com/ "title")
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×3,707
×1,901
×28

question asked: 03 Aug '14, 15:49

question was seen: 1,268 times

last updated: 04 Aug '14, 02:35