×

# Is there something wrong with the following solution to the "Bytelandian gold coins" problem.

 0 Okay, so here's my solution to the "Bytelandian gold coins" problem. #include using namespace std; int main() { unsigned int n; unsigned int n_dollars; int i = 0; while(i < 8) { cin >> n; if(n>=1000000000 || n<=0)break; n_dollars = (13 * n)/12; cout << n_dollars << endl << endl; } return 0; }  But when I submit this program, it says "Time Limit Exceeded". Clearly the above solution does work fine. And I think that this solution is pretty fast. Is there something wrong with my solution or isn't there ? Thanks, Best Regards ! asked 24 Apr '14, 16:46 1●1 accept rate: 0%

 0 Have a look at this i just entered 2 numbers in the input and it printed so many outputs. Also the output was not formatted as required. Before discussing this question, i would suggest that you first have a look at these: TEST and HS08TEST answered 24 Apr '14, 17:02 4★roman28 1.6k●7●14●29 accept rate: 19%
 0 @pravinda333 you have not incremented your variable i which is why your code never exits the while loop. use: while(i<8) { ... i++ } answered 21 Jun '14, 06:08 333●2●3●9 accept rate: 20%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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:

×646
×86
×12

question asked: 24 Apr '14, 16:46

question was seen: 785 times

last updated: 21 Jun '14, 06:08