why can't you edit your post?shantanu18 wrote:i can't edit my post so can not delete my code
406 - Prime Cuts
Moderator: Board moderators
Re: problem 406
Output-406
Remember,
The Output should....
1 1
1 1: 1
(blank space is here)
21 2
21 2: 5 7 11
Now try......
The Output should....
1 1
1 1: 1
(blank space is here)
21 2
21 2: 5 7 11
Now try......
Last edited by faiem on Fri Sep 03, 2010 7:16 am, edited 1 time in total.
Re: 406-WA
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....
The Output should....
10 2
10 2: 2 3 5
1 1
1 1: 1
my mistake is blank space between output....
-
- New poster
- Posts: 3
- Joined: Fri Aug 20, 2010 10:24 am
prime cut..help me...(406)
i am getting W...waiting 4 some suggation....
Re: prime cut..help me...(406)
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
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 !!!!!!!!!!!!
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
here is my implementation using java
Code: Select all
Accepte...d
406 - prime cuts ... WA ?!?!??!!?!?!??!
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
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
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?lnr wrote:Try this case:
Input:Output:Code: Select all
100 51 1000 1000 954 1
Hope it helps.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
Re: problem 406
Hello,
I don't know why, but I seem to be getting WA for my code. Here it is:
^^^^ 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?
I don't know why, but I seem to be getting WA for my code. Here it is:
Code: Select all
Accepted :D
Is it possible that we get an input of N > 1000?
Re: problem 406
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.
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 ...
plz help me .. new line after output dont work ><
my code:
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;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 406 - WA ...
input:
output:
is it right?
Code: Select all
1000 1000
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