## 10101 - Bangla Numbers

All about problems in Volume 101. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 10101 - Bangla Numbers

For input:

Code: Select all

``0``
Ac output is

Code: Select all

``   1. 0``
your code outputs:

Code: Select all

``   1.``
Check input and AC output for thousands of problems on uDebug!

munnapagol
New poster
Posts: 2
Joined: Fri Oct 12, 2012 2:28 am

### Re: 10101 - Bangla Numbers

I have tried a lot of input but again it is showing Runtime error ( RE ).
for input 0 it is showing 0

here is my code please help me

#include<stdio.h>
int main()
{
unsigned long long int num,cas,a,b,c,i,j,k,l,n,d,e,f,g[2000],h,m[2000];
m[0]=0,m[1]=0,m[2]=0,m[3]=0,m[4]=0,m[5]=0,m[6]=0,m[7]=0,m[8]=0,m[9]=0,m[10]=0;
int t;
t=1;

while(scanf("%lld",&num)==1)
{
e=0;
if(num==0)
printf("%d. %lld",t,e);
else
{

while(num!=0)
{
a=num/100;
b=num%100;
m[e]=b;
num=a;
e++;
a=num/10;
b=num%10;
m[e]=b;
num=a;
e++;
a=num/100;
b=num%100;
m[e]=b;
num=a;
e++;
a=num/100;
b=num%100;
m[e]=b;
num=a;
e++;

}
n=1;

for(d=0;d<=e-1;d++)
{
g[n]=m[d];
n++;

}

if(e==12)
n=n-1;
for(h=n-1;h>=1;h--)
{
if(g[h]!=0 );
}
printf("%d. ",t);

for(i=n-1;i>=1;i--)
{
{
if(g!=0 && i==9)
{
if(g!=0 && i==9 && g[8]==0 && g[7]==0 && g[6]==0 && g[5]==0)
{
printf("%lld kuti kuti ",g);
}
else
printf("%lld kuti ",g);
}
else if(g!=0 && i==8 )
{
if(g[7]==0 && g[6]==0 && g[5]==0)
{
printf("%lld lakh kuti ",g);
}
else
printf("%lld lukh ",g);
}
else if(g!=0 && i==7)
{
if(g[6]==0 && g[5]==0)
{
printf("%lld hajar kuti ",g);
}
else
printf("%lld hajar ",g);
}
else if(g[i]!=0 && i==6)
{
if(g[5]==0)
{
printf("%lld shata kuti ",g[i]);
}
else
printf("%lld shata ",g[i]);
}
else if(g[i]!=0 && i==5)
{
printf("%lld kuti ",g[i]);
}
else if(g[i]!=0 && i==4)
{
printf("%lld lukh ",g[i]);
}
else if(g[i]!=0 && i==3)
{
printf("%lld hajar ",g[i]);
}
else if(g[i]!=0 && i==2)
{
printf("%lld shata ",g[i]);
}
else if(g[i]!=0 && i==1)
{
printf("%lld",g[i]);
}

}

}
}

printf("\n");
t++;
}

return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 10101 - Bangla Numbers

The case number should be right aligned in a field of width four. Next time post with the code blocks so the indentation is preserved.
Check input and AC output for thousands of problems on uDebug!

atanu.barai
New poster
Posts: 8
Joined: Fri Feb 28, 2014 9:21 am

### Re: 10101 - Bangla Numbers

Getting WA
Tested the AC inputs and outputs but can not identify the problem
Here is the code

Code: Select all

``````#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <iomanip>

using namespace std;

int main()
{
vector<string> resulto;
string number, temp;
string bangla[]={"","shata","hajar","lakh","kuti"};
int i, len, inputs=0;
bool printed;
while(cin>>number)
{
resulto.clear();
i=0;
printed=false;
inputs++;
cout<<setw(4)<<inputs<<".";
std::size_t found = number.find_first_not_of("0");
if(found == string::npos)
{
cout<<" "<<"0";
}
else
{
number = number.substr(found,number.length());
len = number.length();

while(len>0)
{
if(i==1 || len==1)
{
temp = number.substr(len-1,1);
len=len-1;
}
else
{
temp = number.substr(len-2,2);
len=len-2;
}
if(temp.compare("00") & temp.compare("0"))
{
resulto.push_back(bangla[i]);
resulto.push_back((temp.compare(0,1,"0"))?temp:temp.substr(1,1));
//                    printed=true;
}
else if(i==4)
{
resulto.push_back(bangla[i]);
}
i++;
if(i==5)
i=1;
}
for(int i = resulto.size() - 1; i >= 0; )
{
//                if(printed)
cout <<" "<<resulto[i];
i--;
}
//            if(!printed)
//                cout<<" "<<"0";
}
cout<<endl;
}

}

``````

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 10101 - Bangla Numbers

Don't print a space at the end of a line.
Check input and AC output for thousands of problems on uDebug!

atanu.barai
New poster
Posts: 8
Joined: Fri Feb 28, 2014 9:21 am

### Re: 10101 - Bangla Numbers

Changed the code to

Code: Select all

``````    #include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <iomanip>

using namespace std;

int main()
{
vector<string> resulto;
string number, temp, result;
string bangla[]={"","shata","hajar","lakh","kuti"};
int i, len, inputs=0;
bool printed;
while(cin>>number)
{
resulto.clear();
i=0;
printed=false;
inputs++;
cout<<setw(4)<<inputs<<".";
std::size_t found = number.find_first_not_of("0");
if(found == string::npos)
{
cout<<" "<<"0";
}
else
{
number = number.substr(found,number.length());
len = number.length();

while(len>0)
{
if(i==1 || len==1)
{
temp = number.substr(len-1,1);
len=len-1;
}
else
{
temp = number.substr(len-2,2);
len=len-2;
}
if(temp.compare("00") & temp.compare("0"))
{
resulto.push_back(bangla[i]);
resulto.push_back((temp.compare(0,1,"0"))?temp:temp.substr(1,1));
}
else if(i==4)
{
resulto.push_back(bangla[i]);
}
i++;
if(i==5)
i=1;
}
for(int i = resulto.size() - 1; i >= 0; )
{
result.append(" ");
result.append(resulto[i]);
i--;
}
}
cout<<result.substr(0,result.length()-1);
result.clear();
cout<<endl;
}

}

``````
But still WA

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 10101 - Bangla Numbers

Input:

Code: Select all

``````1058154016
64313759
1499246266
345303916
2067431203
1026951791
1141137498
45091210
178204546
1263315740
820057669
2123434139
1484075687
687821856
685447279
642718242
1534703175
1810464734
846269122
1415953200
2087005692
191355594
671362369
362144343
847435694
998581629
631485954
47442897
1088813208
846285752
1030127030
2146967224
910599511
381889648
344787493
830547067
1408841440
1485924991
875638277
1587045986
601757083
1695695947
1562996477
2085832771
236034155
100960109
581067365
1770737330
1911424843
1427336487
1039206882
1850946887
1618692081
1710569251
65607583
318644127
561667232
697093537
366087024
1650480440
1543379289
1396214054
1649964017
306495153
1778103703
1994751510
1137042220
1039461495
1333192853
2012680497
479023833
1934949937
1560892796
2042020311
1873299060
1796926951
2142980420
306882777
1420180633
1906921615
1734219264
311903867
1610384855
1205427698
2022473119
1675992438
1524071825
436656703
225602327
1890158850
2087137144
1768981616
1138889256
1589617513
2075476769
769509311
1436885375
1065035341
1808970806
622594580
``````
AC output:

Code: Select all

``````   1. 1 shata 5 kuti 81 lakh 54 hajar 16
2. 6 kuti 43 lakh 13 hajar 7 shata 59
3. 1 shata 49 kuti 92 lakh 46 hajar 2 shata 66
4. 34 kuti 53 lakh 3 hajar 9 shata 16
5. 2 shata 6 kuti 74 lakh 31 hajar 2 shata 3
6. 1 shata 2 kuti 69 lakh 51 hajar 7 shata 91
7. 1 shata 14 kuti 11 lakh 37 hajar 4 shata 98
8. 4 kuti 50 lakh 91 hajar 2 shata 10
9. 17 kuti 82 lakh 4 hajar 5 shata 46
10. 1 shata 26 kuti 33 lakh 15 hajar 7 shata 40
11. 82 kuti 57 hajar 6 shata 69
12. 2 shata 12 kuti 34 lakh 34 hajar 1 shata 39
13. 1 shata 48 kuti 40 lakh 75 hajar 6 shata 87
14. 68 kuti 78 lakh 21 hajar 8 shata 56
15. 68 kuti 54 lakh 47 hajar 2 shata 79
16. 64 kuti 27 lakh 18 hajar 2 shata 42
17. 1 shata 53 kuti 47 lakh 3 hajar 1 shata 75
18. 1 shata 81 kuti 4 lakh 64 hajar 7 shata 34
19. 84 kuti 62 lakh 69 hajar 1 shata 22
20. 1 shata 41 kuti 59 lakh 53 hajar 2 shata
21. 2 shata 8 kuti 70 lakh 5 hajar 6 shata 92
22. 19 kuti 13 lakh 55 hajar 5 shata 94
23. 67 kuti 13 lakh 62 hajar 3 shata 69
24. 36 kuti 21 lakh 44 hajar 3 shata 43
25. 84 kuti 74 lakh 35 hajar 6 shata 94
26. 99 kuti 85 lakh 81 hajar 6 shata 29
27. 63 kuti 14 lakh 85 hajar 9 shata 54
28. 4 kuti 74 lakh 42 hajar 8 shata 97
29. 1 shata 8 kuti 88 lakh 13 hajar 2 shata 8
30. 84 kuti 62 lakh 85 hajar 7 shata 52
31. 1 shata 3 kuti 1 lakh 27 hajar 30
32. 2 shata 14 kuti 69 lakh 67 hajar 2 shata 24
33. 91 kuti 5 lakh 99 hajar 5 shata 11
34. 38 kuti 18 lakh 89 hajar 6 shata 48
35. 34 kuti 47 lakh 87 hajar 4 shata 93
36. 83 kuti 5 lakh 47 hajar 67
37. 1 shata 40 kuti 88 lakh 41 hajar 4 shata 40
38. 1 shata 48 kuti 59 lakh 24 hajar 9 shata 91
39. 87 kuti 56 lakh 38 hajar 2 shata 77
40. 1 shata 58 kuti 70 lakh 45 hajar 9 shata 86
41. 60 kuti 17 lakh 57 hajar 83
42. 1 shata 69 kuti 56 lakh 95 hajar 9 shata 47
43. 1 shata 56 kuti 29 lakh 96 hajar 4 shata 77
44. 2 shata 8 kuti 58 lakh 32 hajar 7 shata 71
45. 23 kuti 60 lakh 34 hajar 1 shata 55
46. 10 kuti 9 lakh 60 hajar 1 shata 9
47. 58 kuti 10 lakh 67 hajar 3 shata 65
48. 1 shata 77 kuti 7 lakh 37 hajar 3 shata 30
49. 1 shata 91 kuti 14 lakh 24 hajar 8 shata 43
50. 1 shata 42 kuti 73 lakh 36 hajar 4 shata 87
51. 1 shata 3 kuti 92 lakh 6 hajar 8 shata 82
52. 1 shata 85 kuti 9 lakh 46 hajar 8 shata 87
53. 1 shata 61 kuti 86 lakh 92 hajar 81
54. 1 shata 71 kuti 5 lakh 69 hajar 2 shata 51
55. 6 kuti 56 lakh 7 hajar 5 shata 83
56. 31 kuti 86 lakh 44 hajar 1 shata 27
57. 56 kuti 16 lakh 67 hajar 2 shata 32
58. 69 kuti 70 lakh 93 hajar 5 shata 37
59. 36 kuti 60 lakh 87 hajar 24
60. 1 shata 65 kuti 4 lakh 80 hajar 4 shata 40
61. 1 shata 54 kuti 33 lakh 79 hajar 2 shata 89
62. 1 shata 39 kuti 62 lakh 14 hajar 54
63. 1 shata 64 kuti 99 lakh 64 hajar 17
64. 30 kuti 64 lakh 95 hajar 1 shata 53
65. 1 shata 77 kuti 81 lakh 3 hajar 7 shata 3
66. 1 shata 99 kuti 47 lakh 51 hajar 5 shata 10
67. 1 shata 13 kuti 70 lakh 42 hajar 2 shata 20
68. 1 shata 3 kuti 94 lakh 61 hajar 4 shata 95
69. 1 shata 33 kuti 31 lakh 92 hajar 8 shata 53
70. 2 shata 1 kuti 26 lakh 80 hajar 4 shata 97
71. 47 kuti 90 lakh 23 hajar 8 shata 33
72. 1 shata 93 kuti 49 lakh 49 hajar 9 shata 37
73. 1 shata 56 kuti 8 lakh 92 hajar 7 shata 96
74. 2 shata 4 kuti 20 lakh 20 hajar 3 shata 11
75. 1 shata 87 kuti 32 lakh 99 hajar 60
76. 1 shata 79 kuti 69 lakh 26 hajar 9 shata 51
77. 2 shata 14 kuti 29 lakh 80 hajar 4 shata 20
78. 30 kuti 68 lakh 82 hajar 7 shata 77
79. 1 shata 42 kuti 1 lakh 80 hajar 6 shata 33
80. 1 shata 90 kuti 69 lakh 21 hajar 6 shata 15
81. 1 shata 73 kuti 42 lakh 19 hajar 2 shata 64
82. 31 kuti 19 lakh 3 hajar 8 shata 67
83. 1 shata 61 kuti 3 lakh 84 hajar 8 shata 55
84. 1 shata 20 kuti 54 lakh 27 hajar 6 shata 98
85. 2 shata 2 kuti 24 lakh 73 hajar 1 shata 19
86. 1 shata 67 kuti 59 lakh 92 hajar 4 shata 38
87. 1 shata 52 kuti 40 lakh 71 hajar 8 shata 25
88. 43 kuti 66 lakh 56 hajar 7 shata 3
89. 22 kuti 56 lakh 2 hajar 3 shata 27
90. 1 shata 89 kuti 1 lakh 58 hajar 8 shata 50
91. 2 shata 8 kuti 71 lakh 37 hajar 1 shata 44
92. 1 shata 76 kuti 89 lakh 81 hajar 6 shata 16
93. 1 shata 13 kuti 88 lakh 89 hajar 2 shata 56
94. 1 shata 58 kuti 96 lakh 17 hajar 5 shata 13
95. 2 shata 7 kuti 54 lakh 76 hajar 7 shata 69
96. 76 kuti 95 lakh 9 hajar 3 shata 11
97. 1 shata 43 kuti 68 lakh 85 hajar 3 shata 75
98. 1 shata 6 kuti 50 lakh 35 hajar 3 shata 41
99. 1 shata 80 kuti 89 lakh 70 hajar 8 shata 6
100. 62 kuti 25 lakh 94 hajar 5 shata 80
``````
Check input and AC output for thousands of problems on uDebug!

atanu.barai
New poster
Posts: 8
Joined: Fri Feb 28, 2014 9:21 am

### Re: 10101 - Bangla Numbers

The outputs are the same i think. But getting WA

Code: Select all

``````    #include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <iomanip>

using namespace std;

int main()
{
vector<string> resulto;
string number, temp, result;
string bangla[]={"","shata","hajar","lakh","kuti"};
int i, len, inputs=0;
bool printed;
while(cin>>number)
{
resulto.clear();
i=0;
printed=false;
inputs++;
cout<<setw(4)<<inputs<<".";
std::size_t found = number.find_first_not_of("0");
if(found == string::npos)
{
cout<<" "<<"0";
}
else
{
number = number.substr(found,number.length());
len = number.length();

while(len>0)
{
if(i==1 || len==1)
{
temp = number.substr(len-1,1);
len=len-1;
}
else
{
temp = number.substr(len-2,2);
len=len-2;
}
if(temp.compare("00") & temp.compare("0"))
{
resulto.push_back(bangla[i]);
resulto.push_back((temp.compare(0,1,"0"))?temp:temp.substr(1,1));
}
else if(i==4)
{
resulto.push_back(bangla[i]);
}
i++;
if(i==5)
i=1;
}
for(int i = resulto.size() - 1; i >= 0; )
{
result.append(" ");
result.append(resulto[i]);
i--;
}
}
cout<<result.substr(0,result.length()-1);
result.clear();
cout<<endl;
}
return 0;
}

``````

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 10101 - Bangla Numbers

Input:
1415953200
Output:
1. 1 shata 41 kuti 59 lakh 53 hajar 2 shata
Check input and AC output for thousands of problems on uDebug!

sadmansobhan
New poster
Posts: 16
Joined: Thu Oct 10, 2013 8:06 am

### Re: 10101 - Bangla Numbers

remove
Last edited by sadmansobhan on Tue Apr 29, 2014 8:01 pm, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 10101 - Bangla Numbers

Try input 1415953200, don't print a space at the end of a line.
Check input and AC output for thousands of problems on uDebug!

sadmansobhan
New poster
Posts: 16
Joined: Thu Oct 10, 2013 8:06 am

### Re: 10101 - Bangla Numbers

remove after AC
Last edited by sadmansobhan on Fri May 02, 2014 9:23 pm, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 10101 - Bangla Numbers

Input:

Code: Select all

``````2005871126
``````
AC output:

Code: Select all

``````   1. 2 shata kuti 58 lakh 71 hajar 1 shata 26
``````
Check input and AC output for thousands of problems on uDebug!

sadmansobhan
New poster
Posts: 16
Joined: Thu Oct 10, 2013 8:06 am

### Re: 10101 - Bangla Numbers

got Ac. thanks brianfry713

xplosive
New poster
Posts: 4
Joined: Sat Aug 03, 2013 2:49 pm

### Re: 10101 - Bangla Numbers

Why I am getting PE.
Please help.

Code: Select all

``````//uva set - adhoc
//10101 - Bangla Numbers
//Xplosive
//na

#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<fstream>
#include<numeric>
#include<iterator>
using namespace std;

#define mx 10000000

vector <string> v;

string toString(long long n)
{
stringstream ss;
ss << n;
return ss.str();
}

string getBangla(unsigned long long n)
{
string s;

int m;

int i = 0;
int n1, n2;
n1 = n%mx;

m = n1%100;
if(m)
s = " " +toString(m);
n1 = n1/100;

if(n1)
{
m = n1%10;
if(m)
s = " " +toString(m) + " " + v[i] +  s;
i++;
n1 = n1/10;
}

while(n1)
{
m = n1%100;
if(m)
s = " " +toString(m) + " " + v[i] +  s;
i++;
n1 = n1/100;
}

n2 = n/mx;
if(n2)
{
s = getBangla(n2) + " kuti" + s;

}

return s;

}

int main()
{

freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);

int tt,t=0;
unsigned long long int n;

v.push_back("shata");
v.push_back("hajar");
v.push_back("lakh");
v.push_back("kuti");

while(scanf("%llu",&n)!=EOF)
{
if(n==0)
cout << "   " << ++t << ". 0" << endl;
else
cout << "   " << ++t << "." << getBangla(n) << endl;

}

return 0;
}``````