10190 - Divide, But Not Quite Conquer!
Moderator: Board moderators
I'm confused when we have a sequence of length 1.
When n = 1 and any m, shouldn't we print :
This sequence does not violate any rule, because k = 1:
1) a[1] = 1 and 1 < i <= 1. since there's no such i, that's ok.
2) 1 <= i < 1 the same as above.
3) a[1], also ok.
But I was getting wa when assuming this...
Could someone explain me?
Code: Select all
1
1) a[1] = 1 and 1 < i <= 1. since there's no such i, that's ok.
2) 1 <= i < 1 the same as above.
3) a[1], also ok.
But I was getting wa when assuming this...
Could someone explain me?
Read the second rule
So, is your assumption right?
a is divisible by m (that is, a mod m = 0) for all 1 <= i < k
So, is your assumption right?
Ami ekhono shopno dekhi...
HomePage
HomePage
-
- New poster
- Posts: 9
- Joined: Tue Jul 11, 2006 8:44 am
- Location: Beside you........
why WA??
Why WA???
please help me
please help me
Code: Select all
#include<stdio.h>
#include<string.h>
#include<math.h>
#define eps 0.0000001
int main()
{
int n,m,r,k,k1;
double re;
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
while(scanf("%d %d",&n,&m)!=EOF)
{
if(n==1||m==1)printf("Boring!\n");
else if(n==0||m==0)printf("Boring!\n");
else
{
re=(double)(log(n)/log(m));
k=floor(re);
k1=ceil(re);
//printf("%lf %d %d %lf",re,k,k1,re-k);
if((re-k)<eps||(k1-re)<eps)
{
printf("%d",n);
while(1)
{
r=n/m;
printf(" %d",r);
n=r;
if(r==1)break;
}
printf("\n");
}
else
{
printf("Boring!\n");
}
}
}
return 0;
}
RE..
Some one please help me.... Got Runtime Error.... I couldn't find it....
Last edited by Obaida on Sat Mar 08, 2008 12:30 pm, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.
This may be the address of success.
The given numbers are non negative. So, there can be cases like..
Input:
Output:
And check your spelling.
Input:
Code: Select all
5 0
Code: Select all
Boring!
Thank You
Actually I am so yong to do ACM and become exited.... That's why I get WA.... Now I got Acc.. Thank You..
try_try_try_try_&&&_try@try.com
This may be the address of success.
This may be the address of success.
Re: 10190 - Divide, But Not Quite Conquer!
Code: Select all
Acc At last
![:)](./images/smilies/icon_smile.gif)
10190 TE why? please help me any body
here is my code
Code: Select all
#include<iostream>
#include<queue>
using namespace std;
int main()
{
unsigned long int n,b;
while(1)
{
level:
queue<int>q;
cin>>n>>b;
while(n>1)
{
if(n%b==0){
q.push (n);
n=n/b;
}
else
if(n%b<b&&n>1){
cout<<"Boring!"<<endl;
goto level;
}
}
q.push (1);
while(!q.empty ())
{
cout<<q.front()<<" ";
q.pop ();
}
cout<<endl;
}
return 0;
}
Re: 10190 TE why? please help me any body
now my code is wrong answer
any body give me some critical problem
here is my test cases:
input like:
2 2
1 1
1 0
2 0
2 5
3 6
6 3
125 5
81 3
80 2
output :
2 1
Boring!
Boring!
Boring!
Boring!
Boring!
Boring!
125 25 5 1
81 27 9 3 1
Boring!
Boring!
any body give me some critical problem
here is my test cases:
input like:
2 2
1 1
1 0
2 0
2 5
3 6
6 3
125 5
81 3
80 2
output :
2 1
Boring!
Boring!
Boring!
Boring!
Boring!
Boring!
125 25 5 1
81 27 9 3 1
Boring!
Boring!
Re: 10190 TE why? please help me any body
here is my new code
but i have faced still TLE why?
please help me
but i have faced still TLE why?
please help me
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 <int >q;
if(b==0||n==0||(n==1&&b==1)||n<b)
{
printf("Boring!\n");
continue;
}
while(n>0)
{
if(n%b==0||(n%b==1&&n==1)){
q.push (n);
n/=b;
}
else if(n%b<b&&n%b>=1){
printf("Boring!");
goto l;
}
}
while(!q.empty ())
{
printf("%d ",q.front ());
q.pop ();
}
l:
printf("\n");
}
return 0;
}