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
-
@mjad
- New poster
- Posts: 44
- Joined: Thu Jul 22, 2010 9:42 am
Post
by @mjad »
anybody please help me
Code: Select all
#include<stdio.h>
int main()
{
long int n,b;
long int a[200000],i,j;
//freopen("10190.txt","r",stdin);
while(scanf("%ld %ld",&n,&b)==2)
{
i=0;
if(b==0||n==0||(n==1&&b==1)||n<b)
{
printf("Boring!");
goto l;
}
while(n>0)
{
if(n%b==0||(n==1)){
a[i]=n;
n/=b;
i++;
}
else
{
printf("Boring!");
goto l;
}
}
for(j=0;j<i;j++)
printf("%ld ",a[j]);
l:
printf("\n");
}
return 0;
}
-
@mjad
- New poster
- Posts: 44
- Joined: Thu Jul 22, 2010 9:42 am
Post
by @mjad »
i go AC
thanx a lot for your reply
Last edited by
@mjad on Mon Oct 11, 2010 3:44 am, edited 1 time in total.
-
@mjad
- New poster
- Posts: 44
- Joined: Thu Jul 22, 2010 9:42 am
Post
by @mjad »
please anybody help me
why presentation error?
i think this is write ,
but i don't get AC
my code is here
please any body help me
here is my code
Code: Select all
#include<stdio.h>
#include<queue>
using namespace std;
int main()
{
long int n,b;
while(scanf("%ld %ld",&n,&b)==2)
{
queue<long int>q;
if(n<=1||b<=1)
{
printf("Boring!");
goto l;
}
while(n>0)
{
if(n%b==0||(n==1)){
q.push(n);
n/=b;
}
else
{
printf("Boring!");
goto l;
}
}
while(!q.empty())
{
printf("%ld ",q.front());
q.pop();
}
l:
printf("\n");
}
return 0;
}
-
helloneo
- Guru
- Posts: 516
- Joined: Mon Jul 04, 2005 6:30 am
- Location: Seoul, Korea
Post
by helloneo »
@mjad wrote:please anybody help me
why presentation error?
i think this is write ,
but i don't get AC
my code is here
please any body help me
here is my code
You're printing an extra space after the last number..
-
shoaib7k
- New poster
- Posts: 10
- Joined: Thu Aug 18, 2011 7:45 pm
Post
by shoaib7k »
i got presentation error... here is my code...[/code]
#include<stdio.h>
int main()
{
int n,m,k,i,j,a[200000];
while(scanf("%d%d",&n,&m)!=EOF)
{
i=0;
if(m<2 || n<m)
{
printf("Boring!");
goto l;
}
while(n>0)
{
if(n%m==0 || n==1)
{
a
=n;
n/=m;
i++;
}
else
{
printf("Boring!");
goto l;
}
}
for(j=0;j<i;j++)
printf("%d ",a[j]);
l:
printf("\n");
}
return 0;
}
-
Imran Bin Azad
- New poster
- Posts: 3
- Joined: Thu Jun 03, 2010 8:55 pm
Post
by Imran Bin Azad »
you are printing an extra white space after the last integer
Code: Select all
for(j=0;j<i;j++)
printf("%d ",a[j]);
-
quietroit
- New poster
- Posts: 2
- Joined: Wed Nov 02, 2011 9:06 pm
Post
by quietroit »
you are printing an extra white space after the last integer
Is this what causing a problem?
-
Atish
- New poster
- Posts: 2
- Joined: Fri Jun 10, 2011 5:54 am
Post
by Atish »
if(n>=n&&n!=0&&m!=0&&m!=1&&n!=1) just use this condition and check your printf
-
Atish
- New poster
- Posts: 2
- Joined: Fri Jun 10, 2011 5:54 am
Post
by Atish »
new comer wrote:Whenever I submitt 10190, it says "output limit exceeded". I don't understand where is the problem. My code is like this:
#include<stdio.h>
#include<math.h>
void main()
{
long m,n,result;
for(;(scanf("%ld %ld",&m,&n))==2;)
{
if((ceil(logl(m)/logl(n))) == (floor(logl(m)/logl(n)))) // you should use a condition here and check printf
{
printf("%ld ",m);
for(;;)
{
m=m/n;
printf("%ld ",m);
if(m==1)
break;
}
}
else
{
printf("Boring!");
}
printf("\n");
}
}
HELP ME![/c]
-
shoaib7k
- New poster
- Posts: 10
- Joined: Thu Aug 18, 2011 7:45 pm
Post
by shoaib7k »
what is wrong with my code???
Code: Select all
#include<stdio.h>
int main()
{
int n,m,k,i,h,a[100];
while(scanf("%d%d",&n,&m)==2)
{
if(m<2 || n<2 || n<m)
printf("Boring!");
else
{
k=1;
a[0]=n;
for(i=1;i<=100;i++)
{
a[i]=n/m;
n=a[i];
if(n==0)
break;
k++;
}
for(i=0;i<k-1;i++)
{
if(a[i]%m!=0)
{
printf("Boring!");
goto l;
h=a[i];
break;
}
}
for(i=0;i<k;i++)
printf("%d ",a[i]);
}
l: printf("\n");
}
return 0;
}
-
shoaib7k
- New poster
- Posts: 10
- Joined: Thu Aug 18, 2011 7:45 pm
Post
by shoaib7k »
now i get wrong answer.....
-
brianfry713
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Post
by brianfry713 »
you are printing an extra white space after the last integer
Check input and AC output for thousands of problems on
uDebug!
-
shoaib7k
- New poster
- Posts: 10
- Joined: Thu Aug 18, 2011 7:45 pm
Post
by shoaib7k »
still wrong ans....
-
sajal2k8
- New poster
- Posts: 16
- Joined: Mon Nov 18, 2013 5:15 pm
Post
by sajal2k8 »
Code: Select all
#include <iostream>
using namespace std;
int main()
{
unsigned long long int n,j,m,i=1,num[10000],a,c=0;
while(cin>>n>>m)
{
num[0]=n;
if(n==1)
c=1;
while(n>1 && m!=1)
{
a=n/m;
if(n%m==0)
num[i]=a;
else
{
c=1;
break;
}
n=n/m;
i++;
}
if(m==1 || n==0)
c=1;
if(c==1)
cout<<"Boring!\n";
else
{
for(j=0;j<i;j++)
{
cout<<num[j];
if(j!=i-1)
cout<<" ";
}
cout<<"\n";
}
i=1;c=0;
}
return 0;
}
Thanks in advance..
-
brianfry713
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Post
by brianfry713 »
What if m = 0?
Check input and AC output for thousands of problems on
uDebug!