Page 10 of 13

Re: problem 406

Posted: Tue Jul 27, 2010 12:32 pm
by sohel
shantanu18 wrote:i can't edit my post so can not delete my code
why can't you edit your post?

Output-406

Posted: Thu Sep 02, 2010 12:43 am
by faiem
Remember,
The Output should....
1 1
1 1: 1
(blank space is here)
21 2
21 2: 5 7 11

Now try......

Re: 406-WA

Posted: Thu Sep 02, 2010 7:28 am
by faiem
I found my problem.
The Output should....
10 2
10 2: 2 3 5

1 1
1 1: 1

my mistake is blank space between output....

Re: 406-WA

Posted: Thu Sep 02, 2010 7:30 am
by faiem
Now I got AC...

prime cut..help me...(406)

Posted: Fri Sep 03, 2010 9:16 pm
by refat_ruet
i am getting W...waiting 4 some suggation....

Re: prime cut..help me...(406)

Posted: Sat Sep 04, 2010 9:09 am
by sohel
search the board first using the 'search option' located at the top-right. Don't create a new thread for a problem that already exists, make your post in an existing one.

I am always getting WA but I cannot locate my problem

Posted: Sun Apr 17, 2011 1:26 pm
by anjanpstu

Code: Select all

#include<stdio.h>
#include<math.h>
int main()
{
    int sr[169];int count=2;int flag=1;int i,b;int n,m;int count1=0;int even,odd;int even1,odd1;int even2,odd2;int even3,odd3;

    sr[0]=1;sr[1]=2;sr[2]=3;sr[3]=5;
        for( i=5;i<=1000;i+=2)
        {
            int s=(int)sqrt(i);
          for(int j=2;j<=s;j++)
             {
                  if(i%j!=0)flag=0;
                  else
                  {
                      flag=1;
                      break;
                      }
             }
        if(flag==0)
              {
                  count=count+1;
                  sr[count]=i;
              }
        }


     while((scanf("%d %d",&n,&m))==2)
     {
             count1=0;
             int k=0;
             while(sr[k]<=n)
             {
             count1=count1+1;
             k++;
             }

               printf(" %d %d:",n,m);
             if(count1%2==0)
              {
                  even=m*2;
                 even1=(count1-even);
                   even2=even1/2;
                   even3=even2+even;

                 if(even>=count1)
                 {
                     int k1=0;
                      while(sr[k1]<=n)
                        {
                          printf(" %d",sr[k1]);
                              k1++;
                        }

                 }
                 else if(even<count1)
                 {
                     for(int i=even2;i<even3;i++)
                       printf(" %d",sr[i]);
                 }

              }
              else if(count1%2!=0)
               {
                   odd=(m*2)-1;
                   odd1=(count1-odd);
                    odd2=odd1/2;
                    odd3=odd2+odd;
                   if(odd>=count1)
                      {
                     int k1=0;
                      while(sr[k1]<=n)
                        {
                          printf(" %d",sr[k1]);
                              k1++;
                        }

                     }
                     else if(odd<count1)
                     {
                     for(int i=odd2;i<odd3;i++)
                       printf(" %d",sr[i]);

                     }

       }
       printf("\n\n");
     }
return 0;

  }

406-prime cuts WA why !!!!!!!!!!!!

Posted: Sun May 01, 2011 1:26 pm
by Ahmad
i think the problem is about the i/o ... so please help me cuz i'm not able to figure it out
here is my implementation using java

Code: Select all

Accepte...d

406 - prime cuts ... WA ?!?!??!!?!?!??!

Posted: Sun May 01, 2011 3:28 pm
by Ahmad
i think the problem is about the i/o ... so please help me cuz i'm not able to figure it out
i tested my code alot of times and i always find the expected answer ...
here is my implementation using java

Code: Select all

Accepted

Re: 406 - Prime Cuts

Posted: Tue Oct 04, 2011 5:19 pm
by Asma_ju
lnr wrote:Try this case:
Input:

Code: Select all

100 51
1000 1000
954 1
Output:

Code: Select all

100 51: 1 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

1000 1000: 1 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 947 953 967 971 977 983 991 997

954 1: 419

Hope it helps.
But i don't know how to remove the space before any digit when the output is too long and will be printed in newline.Can anyone please give any idea?

Re: problem 406

Posted: Fri Jul 06, 2012 4:43 am
by abhiramn
Hello,

I don't know why, but I seem to be getting WA for my code. Here it is:

Code: Select all

Accepted  :D 
^^^^ My problem was that I was printing a blank line only between outputs. It clearly states in the problem that a blank line must be there after all outputs, even if it is just one output. People, please be careful about this

Is it possible that we get an input of N > 1000?

Re: problem 406

Posted: Fri Jul 06, 2012 6:51 am
by permalia
I am don't getting this problem.
Sample Input

21 2
18 2
18 18
100 7
Sample Output

21 2: 5 7 11

18 2: 3 5 7 11

18 18: 1 2 3 5 7 11 13 17

100 7: 13 17 19 23 29 31 37 41 43 47 53 59 61 67

i really don't understand the question.would somebody like to help me to get it out.

406 - WA ...

Posted: Thu Dec 20, 2012 4:50 pm
by tommy5198
plz help me .. new line after output dont work ><
my code:

Code: Select all

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cctype>
#include<string>
#include<cmath>
using namespace std;

bool isprime(int t){
    if(t==2||t==3)
        return true;
    else if(t%2==0||t%3==0)
        return false;
    int s=sqrt(t);
    for(int i=2;i<=s;i++)
        if(t%i==0)
            return false;
    return true;
}

int main(){



    int a,b;
    int prime[1000],c=1;
    prime[0]=1;
    for(int i=2;i<1001;i++){
            if(isprime(i)){
                prime[c]=i;
                c++;
        }
    }
    while(cin>>a>>b){
        for(c=0;c<1000;c++)
            if(prime[c]>a)
                break;


        cout<<a<<" "<<b<<":";
        if(c%2){
            if(2*b-1>c)
                for(int i=0;prime[i]<=a;i++)
                    cout<<" "<<prime[i];
            else
                for(int i=c/2-b+1;i<=c/2+b-1;i++)
                    cout<<" "<<prime[i];
        }else{
            if(2*b>c)
                for(int i=0;prime[i]<=a;i++)
                    cout<<" "<<prime[i];
            else
                for(int i=c/2-b;i<=c/2+b-1;i++)
                    cout<<" "<<prime[i];
        }
        cout<<"\n\n";
    }
    return 0;
}

Re: 406 - WA ...

Posted: Thu Dec 20, 2012 9:05 pm
by brianfry713
Try input 1000 1000

Re: 406 - WA ...

Posted: Fri Dec 21, 2012 3:46 pm
by tommy5198
input:

Code: Select all

1000 1000
output:

Code: Select all

1000 1000: 1 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 947 953 967 971 977 983 991 997

is it right?