the code seems fine to me..but getting wa..
#include<stdio.h>
int main(){
int a,b,i,sum;
printf("PERFECTION OUTPUT\n");
while(scanf("%d",&a)==1){
sum=0;
if(a==0) {printf("END OF OUTPUT");break;}
else{
for(i=1;i<=a/2;i++){
b=a%i;
if(b==0) sum=sum+i;
}
if(sum==a) printf ...
Search found 4 matches
- Thu Jul 23, 2009 10:24 pm
- Forum: Volume 3 (300-399)
- Topic: 382 - Perfection
- Replies: 95
- Views: 35297
- Sat Jul 04, 2009 8:03 pm
- Forum: Volume 107 (10700-10799)
- Topic: 10783 - Odd Sum
- Replies: 34
- Views: 22117
Re: 10783 - Odd Sum
getting wa...why??can anyone plz help me..
#include<stdio.h>
int main(){
int a,b,i,j,k,sum,c;
while(scanf("%d",&k)==1){
c=0;
for(i=0;i<k;i++){
scanf("%d %d",&a,&b);
sum=0; c++;
for(j=a;j<=b;j++){
if(j%2==1) sum=sum+j;
else continue;
}
printf("case %d:%d\n",c,sum);
}
}
return 0;
}
#include<stdio.h>
int main(){
int a,b,i,j,k,sum,c;
while(scanf("%d",&k)==1){
c=0;
for(i=0;i<k;i++){
scanf("%d %d",&a,&b);
sum=0; c++;
for(j=a;j<=b;j++){
if(j%2==1) sum=sum+j;
else continue;
}
printf("case %d:%d\n",c,sum);
}
}
return 0;
}
- Thu Jul 02, 2009 4:27 pm
- Forum: Volume 5 (500-599)
- Topic: 591 - Box of Bricks
- Replies: 80
- Views: 24923
Re: 591
i m getting wa..y??can anyone plz help me....
#include<stdio.h>
int main(){
int x[100],n,sum,a,b,i,j=1;
while(scanf("%d",&n)==1)
{sum=0;
b=0;
if(n!=0 && n>=1 && n<=50)
{
for(i=0;i<n;i++)
{
scanf("%d",&x );
if(x >=1 && x <=100)
{
sum=sum+x ;
}
else break;
}
if(sum%n==0)
{
a=sum/n ...
#include<stdio.h>
int main(){
int x[100],n,sum,a,b,i,j=1;
while(scanf("%d",&n)==1)
{sum=0;
b=0;
if(n!=0 && n>=1 && n<=50)
{
for(i=0;i<n;i++)
{
scanf("%d",&x );
if(x >=1 && x <=100)
{
sum=sum+x ;
}
else break;
}
if(sum%n==0)
{
a=sum/n ...
- Mon Jun 22, 2009 9:29 am
- Forum: Volume 100 (10000-10099)
- Topic: 10055 - Hashmat the Brave Warrior
- Replies: 166
- Views: 77229
Re: 10055 - Hashmat the Brave Warrior
m a beginner in acm..this is the first problem i m trying to solve ..nd having a lot of difficulties in understanding..watz wrong in my code..can anyone help me??
here's my code:
#include<stdio.h>
void main()
{
long long int i,j;
while(scanf("%lld %lld",&i,&j)==2)
{
if(i<j) printf("%lld\n ...
here's my code:
#include<stdio.h>
void main()
{
long long int i,j;
while(scanf("%lld %lld",&i,&j)==2)
{
if(i<j) printf("%lld\n ...