Page 5 of 6
Posted: Wed May 24, 2006 1:08 am
0/15 = 0.0(0)
0 = number of digits in repeating cycle
.

It's it right!? I've got an beautiful "runtime error" Posted: Mon Mar 12, 2007 5:29 pm
i really confuse.. why always get WA??...

Code: Select all

``````Accepted after re-code..
``````
Thx for Jan.. I know my mistake..

Posted: Mon Mar 12, 2007 8:28 pm
Try the cases...

Input:

Code: Select all

``````41 468
1169 725
2962 465
2705 1146
2281 1828
961 492``````
Output:

Code: Select all

``````41/468 = 0.08(760683)
6 = number of digits in repeating cycle

1169/725 = 1.61(2413793103448275862068965517)
28 = number of digits in repeating cycle

2962/465 = 6.3(698924731182795)
15 = number of digits in repeating cycle

2705/1146 = 2.3(60383944153577661431064572425828970331588132635253...)
95 = number of digits in repeating cycle

2281/1828 = 1.24(78118161925601750547045951859956236323851203501094...)
152 = number of digits in repeating cycle

961/492 = 1.95(32520)
5 = number of digits in repeating cycle``````
Hope these help.

Posted: Sun Jun 24, 2007 6:24 am
Output:

Code: Select all

``````1/397 = 0.(00251889168765743073047858942065491183879093198992...)
99 = number of digits in repeating cycle

why you breaking it down in three lines? i got PE.  my output was like

[code]
2099/1 = 2099.(0)
1 = number of digits in repeating cycle

20/20 = 1.(0)
1 = number of digits in repeating cycle

10/9 = 1.(1)
1 = number of digits in repeating cycle

1001/998 = 1.0(0300601202404809619238476953907815631262525050100...)
498 = number of digits in repeating cycle

890/901 = 0.(98779134295227524972253052164261931187569367369589...)
208 = number of digits in repeating cycle

2999/928 = 3.23168(1034482758620689655172413793)
28 = number of digits in repeating cycle

``````
any idea?

Posted: Sun Jun 24, 2007 2:44 pm

Posted: Mon Jun 25, 2007 12:18 am
okay i have fixed it.

so to print a new line you have to use "\n"?? "cout<<endl;" does not work??

Posted: Mon Jun 25, 2007 10:50 am
dulon wrote: so to print a new line you have to use "\n"?? "cout<<endl;" does not work??
Both should work.

### help me

Posted: Thu Aug 23, 2007 7:14 pm
my program gives right output for all the input given in this page.but i am getting wr.

Code: Select all

``````  remove after AC
``````

Posted: Thu Aug 23, 2007 11:05 pm
Check the output...

Output:

Code: Select all

``````2943/2996 = 0.98(23097463284379172229639519359145527369826435246995...)
318 = number of digits in repeating cycle``````
Hope it helps.

Posted: Thu Aug 23, 2007 11:28 pm
thanks jan.i have acepted now.

### 202 RE...

Posted: Fri Dec 25, 2009 1:05 pm
Hi, guys... Could somebody help me find what's wrong with my 202 code..
The system replay I have a Runtime error. But I can't find what's wrong.
I also increase the arraysize to 2000 but it still doesn't work.
BTW, my coding is not good. I'll appreciate if anyone can give any advice to revise my code.

//ACM 202 Repeating decimals
#include <iostream>
using namespace std;

int main(void){
int n1, n2;
int decimals;
int remainder;
int coef = 0;
int idx = 0;
bool found = false;
int length = 0; //Count the number of repeating cycle
int startIdx = 0;
while (cin>> n1>> n2){
idx = 0;
startIdx = 0;
length = 0;
found = false;
cout << n1 << "/" << n2 << " = " << static_cast<int>(n1/n2) << "." << flush;
while(!found){
if (n1/n2)
n1 = n1 - static_cast<int>(n1/n2) * n2;
n1 *= 10;
remainder[idx] = n1 % n2;
decimals[idx] = n1/n2;
// Find the repeat remainder
for (int i = 0; i != idx; i++) {
if (remainder == remainder[idx]){
found = true;
if (remainder[idx] == 0) // Means A|B
{
length = 1;
startIdx = idx;
found = true;
break;
}
else{
length = idx - i;
startIdx = i;
}
}
}
if (!found)
idx++;
}
if (length <= 1) // Means A|B
{
for (int k = 0; k != idx; k++)
cout << decimals[k];
cout << "(" << decimals[idx] << ")" << endl;
}
else { // Means A can not divided by B.. It has remainder
for (int k = 0; k != idx; k++) {
if (k == 50) {
cout << "...";
break;
}
if (k == startIdx)
cout << "(";
cout << decimals[k] ;
}
cout << ")" << endl;
}
cout << " " << length << " = number of digits in repeating cycles" << endl;
cout << endl;
}
//system("pause");
return 0;
}

### Re: 202 RE...

Posted: Sun Nov 14, 2010 1:11 pm
The problem states that "None of the input integers exceeds 3000",
so, array size of 2000 is not enough but 3000 is enough.

### UVA 202

Posted: Sun Apr 24, 2011 3:58 pm
I have tried all the test cases can be found in the site?and all i'o are correct?and I do not know what's wrong with my cod.
Help me,plz;
Or if you give me some critic I/OI will also appreciate if you give me some critic I/O
Here is my code

Code: Select all

``````#include<iostream>
#include<cstring>
#include<stdio.h>
#define SIZE 50000
#define MAX 50
using namespace std;
int main()
{
int surplus[SIZE],digit[SIZE],place[SIZE],t,te,tem,temp,a,b;
bool index=false;
while(cin>>a>>b)
{
if(cin.eof())
return 0;
if(index)
cout<<endl;
t=a/b;
te=a-t*b;
te*=10;
memset(surplus,0,sizeof(surplus));
tem=1;
surplus[te]=tem;
while(1)
{
if(te<b)
{
te*=10;
digit[tem]=0;
++tem;
}
else
{
digit[tem]=te/b;
te=te%b;
te*=10;
++tem;
}
if(surplus[te])
break;
surplus[te]=tem;
}
te=surplus[te];
printf("%d/%d = %d.",a,b,t);
temp=1;
while(temp<te)
{
cout<<digit[temp];
++temp;
}
cout<<'(';
if(tem-temp>49)
{
t=temp+50;
while(temp<t)
{
cout<<digit[temp];
++temp;
}
printf("...)\n   %d = number of digits in repeating cycle\n",tem-te);
}
else
{
while(temp<tem)
{
cout<<digit[temp];
++temp;
}
printf(")\n   %d = number of digits in repeating cycle\n",tem-te);
}
index=true;
}
return 0;
}

``````

### Re: UVA 202

Posted: Fri Sep 02, 2011 10:56 pm
Try adding a newline at the end of the output. It seems like that should cause a PE but for this problem it considers it a WA.

### Re: 202-why WA?

Posted: Fri Sep 02, 2011 11:00 pm
Check that you're using three spaces before the number not one - the forum software takes out extra spaces.

Also add a newline at the end of the output.