Why do I get Wrong Answer?

,

Anyone tell me plz whats wrong in this?
https://www.codechef.com/viewsolution/9360275

my program is right… i dont know why its always give wrong answer

#include<stdio.h>
int main()
{
unsigned int t,n,sum=0,x=0;
int count=0;
scanf("%d",&t);
while(t>0)
{
scanf("%d",&n);
x=n;
while(n>=1 && count==0)
{
if(n>=100)
{
n=x%100;
sum=sum+(x/100);
x=n;
}
else if(n>=50)
{
n=x%50;
sum=sum+(x/50);
x=n;
}
else if(n>=10)
{
n=x%10;
sum=sum+(x/10);
x=n;
}
else if(n>=5)
{
n=x%5;
sum=sum+(x/5);
x=n;
}
else if(n>=2)
{
n=x%2;
sum=sum+(x/2);
x=n;
}
else
{
sum=sum+1;
count++;
}
}
printf("%d\n",sum);
sum=0;
t–;
}
return 0;
}

#include<stdio.h>
int main()
{
int t;int i,j;
int a[100];
long f;
scanf("%d",&t);
for(i=0;i<t;i++)
scanf("%d",&a[i]);
for(i=0;i<t;i++)
{
f=1;
for(j=1;j<=a[i];j++)
{
f=f*j;
}
printf("%ld\n",f);
}
return 0;
}

I have run this in visual studio…output is correct still it is giving wrong answer

question is this:
You are asked to calculate factorials of some small positive integers.

Input

An integer t, 1<=t<=100, denoting the number of testcases, followed by t lines, each containing a single integer n, 1<=n<=100.

Output

For each integer n given at input, display a line with the value of n!

Example

Sample input: 4
1
2
5
3

Sample output:
1
2
120
6

#include
#include
using namespace std;

int main() {
	
int n[10];

for(int a = 0; a<10; a++)
{
	cin>>n[a];
}
for(int x = 0; x <10; x++){
	if (n[x]==42)
	break;
	else	{
		cout<<n[x]<<"\n";
	}
}
	return 0;
}

Why do I get wrong answer? However the program runs perfectly on local machine but on codechef it says wrong answer! Please help.

This is my code in python3 for beginner COLOUR problem and it gives correct answer for all sample input. But still the result is “Wrong answer”?

t=int(input())                                                              #no. of test cases
while t>0:
    n=int(input())                                                          #no of rooms in chef's house
    s=str(input())                                                          #colour config
    mnr=0
    cr=0
    cb=0
    cg=0
    for st in s:
        if st=="R" or st=="B" or st=="G":
            if st=="R":
                    cr+=1
            elif st=="B":
                    cb+=1
            elif st=="G":
                    cg+=1
    if cr==cb and cr==cg:
        mnr=cr*2
    else:
        mnr=n-max(cr,cb,cr)
    print(mnr)
    t-=1

I’ve tried to find answer to your problem. Test your program by some custom test cases and check the output, the results show why your program isn’t passing all test cases. I hope you can fix them by yourself. For more reference seek help from custom essay writing service.

thanks you friend

#include
using namespace std;
int main()
{
string s;
int n,k;

cin>>k;
for(int j=0;j<k;j++)
{

cin>>s;
n=s.size();
for(int i=n;i>=0;i--)
    cout<<s[i];
cout<<"\n";
}

}

I’ve tested the code but it gives me a wrong answer can anyone tell me why??

#include
#include
using namespace std;

int main() {

long long int t,i,n,w,c;

// your code goes here

cin>>t;



while(t--)

{c=0;
      cin>>n;

   char a[n],b[n];

  long long  int w[n+1];

    
    for(i=0;i<n;i++)

   { cin>>a[i];
   if(a[i]<65||a[i]>90)
   a[i]='_';
   }
  
    for(i=0;i<n;i++)

    { cin>>b[i];
   if(a[i]<65||a[i]>90)
   a[i]='_';
   }

    for(i=0;i<(n+1);i++)

    cin>>w[i];
   

    for(i=0;i<n;i++)

    {

    if(a[i]==b[i])

    c++;

    }
    cout<<w[c]<<endl;

}
return 0;
}

Why am I getting wrong answer?

Why am I getting a wrong answer?

#include
#include
using namespace std;
int main()
{
int a ;
double b;
cin >> a>> b;
if ((0< a<=2000) &&(0<=b<=2000) && (a <= b ))
{
if( a % 5 == 0 )

	cout <<fixed << setprecision(2)<<  b - a - 0.50 << "\n" ;

else 
     cout << fixed << setprecision(2) << b << "\n";

}
else
cout << fixed << setprecision(2) << b<< “\n”;
}

why m i getting wrong answer in this …question code CLEANUP?

#include<stdio.h>
main()
{
int T,t,n,m,i,k,N[1000],j,flag,chef[1000],asst[1000],x;
scanf("%d",&t);
for (T=0;T<t;T++)
{
scanf("%d",&n);
scanf("%d",&m);
for(i=0;i<=n-1;i++)
{
N[i]=1;
}

   for(i=0;i<=m-1;i++)
   {
         scanf("%d",&x);
         N[x-1]=0;
         
       }
   flag=0;
   k=0;
   j=0;
   for(i=0;i<=n-1;i++)
   {
        if(N[i]==1)
        {
           if(flag==0)
           {
           chef[k]=i+1;
           k++;
           flag=1;        
           }
           else
           {
            asst[j]=i+1;
           j++;
           flag=0;  
          }
        }
   }
    for(i=0;i<=k-1;i++)
     {
        printf("%d",chef[i]);
     }
     printf("\n");
    for(i=0;i<=j-1;i++)
     {
        printf("%d",asst[i]);
     }
     printf("\n");
  }
   return 0;

}

#include<stdio.h>
#include<stdlib.h>
int main()
{
long long t,n,i,j,m,s,x,o,a,b;
scanf("%lld",&t);
while(t–)
{
o=0;
scanf("%lld",&n);
char A[n];
long long B[n];
scanf("%s",A);
for(i=0;i<n;i++)
scanf("%lld",&B[i]);
for(i=0;i<n;i++)
{
m=100000000;
if(A[i]==48)
{
for(j=0;j<n;j++)
{
if(A[j]==49)
{
s=abs(B[j]-B[i]);
if(m>s)
{
m=s;
x=j;
}
}
}
o+=abs(B[x]-B[i]);
A[i]=49;
}
}
printf("%lld\n",o);
}
return 0;
}
why i get WA

#include<stdio.h>
int main(){
int t,n;
int a[200];

scanf("%d",&t);
while(t–){
scanf("%d",&n);
int temp=0;
int i=2;
a[0]=1;
int m=1;
int x;
while(i<=n){
int index=0;
while(index<m){
x=a[index]*i+temp;
a[index]=x%10;
temp=x/10;
index++;
}
while(temp!=0){
x=temp%10;
a[index]=x;
temp=temp/10;
m++;
index++;
}
i++;

}
int k;
for( k=m-1;k>=0;k–)
printf("%d",a[k]);

}

}

Why my answers is wrong ??

#include
using namespace std;

int main()
{
int x;
float y;
cin>>x>>y;
if(x%5!=0 || x>=y)
{
cout<<y<<endl;
}

else if(x%5==0)
{
    cout<<y-x-0.5<<endl;
}

return 0;

}
why am i getting wrong answer?

Check this code for this problem - Ice Cream Problem
Working perfectly for sample example - My Solution

why i get wrong answer

#include<stdio.h>
main()
{
int a[100];
int cnt=0,i=0,j=0;
printf(“enter no of digit”);
scanf("%d",&j);
printf(“enter”);
for(i=0;i<=j;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<=j;i++)
{
if(a[i]!=42)
printf("%d",a[i]);
else
break;
}
}
what is wrong with this code???

if it’s from a live contest u mustn’t share it even if it’s partial you may be disqualified for this

#include <stdio.h>
#include <string.h>

int main(void)
{
int T;
int win = 0;
int lose = 0;
char S[100];

do 
{
    scanf("%d",&T);
}
while ( T < 0 || T > 1000);

for(int j = 0; j < T;j++)
{
scanf("%s",S);

for(int i = 0; i < strlen(S); i++)
{
    if(S[i] != '1')
        ++lose;
    else
        ++win;
}

if (win > lose)
    printf("WIN\n");
else
    printf("LOSE\n");

}
 return 0;   
}

why WA ?

import java.util.*;
class cd2
{
public static void main(String ar[])
{
Scanner s=new Scanner(System.in);
Long T,D;
T=s.nextLong();
while(T–!=0)
{
D=s.nextLong();
Long w,z;
w=(long)0;
z=(long)0;
while(D>0)
{
if(D%10==1)
w++;
else
z++;
D=D/10;
}
if((w==1)||(z==1))
System.out.println(“Yes”);
else
System.out.println(“No”);
}
}
}

It’s giving wrong answer.