Page 3 of 4
OLE of 408
Posted: Sat Mar 03, 2007 5:35 am
by Md.Arafat Hossain
Why output limit exceed,please help me
here is my code:
#include<stdio.h>
int main(){
int step,seed=0,mod,i,k;
while(scanf("%d%d",&step,&mod)==2){
i=0;
seed=0;
k=seed;
seed=(seed+step)%mod;
i++;
while(seed!=k){
seed=(seed+step)%mod;
i++;}
printf("%10d%10d",step,mod);
if(mod==i)
printf(" Good Choice");
else
printf(" Bad Choice");
printf("\n");
}
return 0;
}
Posted: Mon Mar 05, 2007 10:29 pm
by Debashis Maitra
Change
Code: Select all
while(scanf("%d%d",&step,&mod)==2)
To
Code: Select all
while(scanf("%d %d",&step,&mod)==2)
I think that will help you
And to avoid PE carefully read the output format
For each line of input, your program should print the STEP value right- justified in columns 1 through 10, the MOD value right-justified in columns 11 through 20 and either ``Good Choice" or ``Bad Choice" left-justified starting in column 25. The ``Good Choice" message should be printed when the selection of STEP and MOD will generate all the numbers between and including 0 and MOD-1 when MOD numbers are generated. Otherwise, your program should print the message ``Bad Choice". After each output test set, your program should print exactly one blank line.
Posted: Mon Mar 05, 2007 11:21 pm
by Jan
Debashis Maitra wrote:Change
Code: Select all
while(scanf("%d%d",&step,&mod)==2)
To
Code: Select all
while(scanf("%d %d",&step,&mod)==2)
Debashis, both are correct.
Md.Arafat Hossain, your code looks ok. But your output format is not correct. There is no reason to get OLE. And don't open a new thread if there is one already. Use existing threads.
Posted: Tue Mar 06, 2007 8:05 pm
by Debashis Maitra
Jan bhai you are right
But I dont understand why his problem is OLE
It should be PE
Posted: Wed Mar 07, 2007 2:56 am
by helloneo
His code gives PE not OLE..
Posted: Tue Mar 20, 2007 6:24 pm
by Md.Arafat Hossain
Thanks jan bhaia and Debashis.
408 P.E.........Please help
Posted: Tue May 22, 2007 10:16 pm
by ankit.arora
This is my code for prob 408 in which i m getting repeated P.E
please help!!!!
Code: Select all
#include<iostream>
using namespace std;
int main()
{
int step,mod;
while(cin>>step>>mod)
{
int arr[100010],set=0,prev,i,j,count,seed;
for(j=0;j<mod;j++)
arr[j]=0;
prev=0;
count=0;
while(1)
{
if(count==mod)
{
set=1;
break;
}
seed=(prev+step)%mod;
if(arr[seed]!=1)
{
arr[seed]=1;
prev=seed;
count++;
}
else
break;
}
cout<<" ";
i=100000;
while(i>step)
{
cout<<" ";
i/=10;
}
cout<<step;
cout<<" ";
i=100000;
while(i>mod)
{
cout<<" ";
i/=10;
}
cout<<mod;
if(set==1)
cout<<" Good Choice\n\n";
else
cout<<" Bad Choice\n\n";
}
}
[/code]
Posted: Wed May 23, 2007 8:42 pm
by Jan
Search the board and post your problem in an existing thread.
P.E. in 408
Posted: Thu May 24, 2007 3:00 pm
by ankit.arora
I am getting P.E. in 408...... someone please help!
Code: Select all
#include<iostream>
using namespace std;
int main()
{
int step,mod;
while(cin>>step>>mod)
{
int arr[100010],set=0,prev,i,j,count,seed;
for(j=0;j<mod;j++)
arr[j]=0;
prev=0;
count=0;
while(1)
{
if(count==mod)
{
set=1;
break;
}
seed=(prev+step)%mod;
if(arr[seed]!=1)
{
arr[seed]=1;
prev=seed;
count++;
}
else
break;
}
cout<<" ";
i=100000;
while(i>step)
{
cout<<" ";
i/=10;
}
cout<<step;
cout<<" ";
i=100000;
while(i>mod)
{
cout<<" ";
i/=10;
}
cout<<mod;
if(set==1)
cout<<" Good Choice\n\n";
else
cout<<" Bad Choice\n\n";
}
}
PE in 408
Posted: Sun May 27, 2007 11:14 pm
by That's Good
Ankit To avoid the presentation error , Just look out in which coumn your code is being printed. To get help you can copy the spaces from the problem.
**printf("%10ld%10ld Good Choice\n"):**
***Use four space before Good/Bad Choice***
this code might be helpful.
Try it out.

WA helppp
Posted: Thu Jun 28, 2007 9:21 am
by NaIx
i submit my code but i'm get WA... i didn't know where the problem... so somebody help plsss..... tq
Code: Select all
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#define MAX 100000
long int seed[MAX];
long int temp[MAX];
int main()
{
long int step, mod, cek, i;
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
while(scanf("%ld %ld",&step,&mod)==2)
{
memset(seed,0,sizeof(seed));
memset(temp,0,sizeof(temp));
for(i=1;i<mod;i++)
{
seed[i]=(seed[i-1]+step)%mod;
temp[seed[i]]=1;
}
for(i=1;i<mod;i++)
{
if(temp[i]==1)
cek=1;
else cek=0;
}
printf("%10ld%10ld ",step,mod);
if(!cek) printf("Bad Choice\n\n");
else printf("Good Choice\n\n");
}
return 0;
}
Posted: Thu Jun 28, 2007 1:56 pm
by Jan
Your output format is not correct.
408....RE .....anyone plz help
Posted: Sun Jan 20, 2008 9:47 pm
by seeking help
my code is giving re. i couldnt find out the reason why?anyone plz help me to understand...
include<stdio.h>
#include<string.h>
int main()
{
long int step,modd,seed,seed1,cnt;
while(scanf("%ld%ld",&step,&modd)==2)
{
seed=0;
cnt=0;
seed1=(seed+step)%modd;
cnt++;
while(1)
{
if(seed1==0)
break;
seed1=(seed1+step)%modd;
cnt++;
}
printf("%10ld%10ld",step,modd);
if(cnt==modd)
printf(" Good Choice");
else
printf(" Bad Choice");
printf("\n\n");
}
return 1;
}
Posted: Sun Jan 20, 2008 9:54 pm
by mf
main() should return 0.
Non-zero exit code conventionally means an error.
408WA..Help
Posted: Sat Feb 09, 2008 10:10 am
by AcmNightivy
Could someone help to find my mistake..i get puzzled..Thanks..And why
gcd (step, mod) == 1 is a Good Choice(found in other thread)..
Code: Select all
#include <stdio.h>
#include "string.h"
bool exist[10000001];
int main ()
{
int step, mod, l, i;
bool flag;
bool first = true;
while (scanf ("%d%d", &step, &mod) != EOF) //(L+step) % mod
{
if (first)
first = false;
else
printf ("\n");
flag = true;
l = 0;
memset (exist, 0, 10000001);
exist[l] = true;
l = (step + l) % mod;
while (!exist[l])
{
exist[l] = true;
l = (step + l) % mod;
}
printf ("%10d%10d ", step, mod);
for (i = 0; i < mod; i++)
if (exist[i] == false)
{
flag = false;
break;
}
if (flag)
printf ("Good Choice\n");
else
printf ("Bad Choice\n");
}
return 0;
}