×

# Why do I get Wrong Answer?

 1 1 Why is my program getting wrong answer? asked 22 Mar '13, 16:31 2★anup ♦♦ 2.4k●27●39●44 accept rate: 21%

 2 just check out that your program is following the constraints given in the problem. try to take input just as the given in constraints. This will help you to determine whether your logic is correct or not. Hope this helps you!! answered 02 Feb '17, 02:22 2★vikisahu 21●1 accept rate: 0%

# include <iostream>

using namespace std; int main(){ int i; cin >> i; while(i != 42){ cout << i; cin >> i; } return(0);

}
Its showing wrong answer.why is it so?


211
accept rate: 0%

1

Hey please add new line in your code in output section then you will surely get AC

(02 Jan '15, 00:46)
1

Because You have missed "\n" after cout<<i statement.

(02 Jan '15, 00:49) 3★
 1 You should print '\n' after each output. include using namespace std; int main(){ int i; cin >> i; while(i != 42){ cout << i<> i; } return(0); }  answered 02 Jan '15, 00:46 29●6 accept rate: 0%
 0 #include using namespace std ; int main(){ int N ; cin >> N ; while(N!=42){ cout << N << endl ; cin >> N ; } return 0; }  same code got Ac with this endl statement .. answered 02 Jan '15, 00:49 1.7k●1●17●30 accept rate: 11%
 0 thank you very much answered 11 Jan '15, 16:49 0★gaafer 1 accept rate: 0%

# include<stdio.h>

int main() { int x,i,j; int a[99]; printf("how many num you want to enter"); scanf("%d",&x); for(i=0;i<x;i++) { scanf("%d",&a[i]); } for(i=0;i<x;i++) { if(a[i]!=42) printf("%d\n",a[i]); else exit(1); } return 0; }

3★kaanchi
1
accept rate: 0%

 0 import re import math def function(n): i=1 sum1=1 while n: x=math.pow(i,i) sum1=sum1x i=i+1 n=n-1 sum1=int(sum1) return sum1 def main(): sum3=0#to calculate the sum of n testcases sum2=0 d=list() t=int(raw_input('')) while t>0: n=int(raw_input('')) m=int(raw_input('')) q=int(raw_input('')) try: if n>2 and n<100001: sum3=sum3+n if m>1 and m<1000000001: while q>0: r=int(raw_input('')) if r>1 and r
 0 I am able to get all the answers for the sample inputs given in the problem. But still I get "Wrong answer". answered 08 Feb '15, 20:32 1 accept rate: 0% 1 Sample inputs are just public test cases but your code need to pass all the public as well as private test cases.you can follow this link for more info...https://www.quora.com/What-is-the-advice-you-would-give-a-beginner-whose-code-passes-all-public-test-cases-but-fails-around-40-50-of-test-cases (22 Feb '17, 11:35)
 0 You might be missing a few other conditions, always check your program for many different conditions. Also if in your output you give something like " The answer is 3 ", instead of simply outputting 3, you will get a wrong answer. Its best to show your code and then ask. answered 08 Feb '15, 20:48 1★arun_as 741●3●6●18 accept rate: 10%
 0 Hi Arun, Is it ok for me to show the entire code? It's from one of the challenges problem answered 09 Feb '15, 18:55 1 accept rate: 0% if it's from a live contest u mustn't share it even if it's partial you may be disqualified for this (07 Sep '16, 01:50)
 0 import java.util.Scanner; class ChefChain { void compute() { try { int count1 =0,count2=0; Scanner sc = new Scanner(System.in); Scanner sc1 = new Scanner(System.in); int t = sc.nextInt(); String s[] = new String[t]; int a1[] = new int[t]; for(int i = 0;i0) System.out.println(); System.out.print(a1[i]); } } catch(Exception e) { } } public static void main(String args[]) { new ChefChain().compute(); } } this show wrong answer.. what shud i do answered 11 Feb '15, 01:11 1 accept rate: 0%
 0 http://www.codechef.com/viewsolution/6486351 please check this is correct answer given for every input but why shoe wa??? ple check answered 13 Mar '15, 11:27 4★grb47 1 accept rate: 0%

tell me whats wrong in this program of finding factorials of small numbers i am getting as wrong answer

# include<stdio.h>

int fact(int n) { int a; if(n==0) a=1; else a=n*fact(n-1); return a; } int main() { int i,t,a[100],ans[100]; scanf("%d",&t); for(i=0;i<t;i++) {="" scanf("%d",&a[i]);="" if((a[i]="">=1)&&(a[i]<=100)) ans[i]=fact(a[i]); } for(i=0;i<t;i++) printf("%d\n",ans[i]);

return 0; }

1
accept rate: 0%

# include<stdio.h>

void main()

{int n; scanf("%d",&n); while(n!=42)

{ if(n!=42) printf("%d",n); scanf("%d",&n);

} }

what is wrong in this code???

-1
accept rate: 0%

 0 you sshould use endl ornewline statement... answered 17 Mar '15, 03:51 1 accept rate: 0%
 0 wasted hours rechecking my code...still cant figure out what's wrong.... here's my code for problem small factorials aka FCTRL2... # include < stdio.h> int main() { int carry,i,j,n,m,l,sum,k; sum=0; scanf("%d",&n); int num[101]={0}; for( m=0 ;m < n;m++) { scanf("%d",&num[m]); } for(l=0;l < n;l++) { int digit[501]={0}; digit[0]=1; int temp; for(j=2;j<=num[l];j++) { for(i=0;i<500;i++) { temp=(digit[i]*j)+carry; if(temp>9) { digit[i]=temp%10; carry=temp/10; } else if(temp<=9) { digit[i]=temp; carry=0; } } } int v=500; while(digit[v]==0) { v--; } for(k=v;k>=0;k--) { printf("%d",digit[k]); } printf("\n"); } return 0; } the code even works for much larger factorials...dont know why it isnt accepted...pls help.. answered 25 Mar '15, 20:31 0★agrwl 1●1 accept rate: 0%

# include <stdio.h>

int main()

{int i,n;

for(i=0;;i++)

{scanf("%d",&n);

if(n==42)

break;

printf("%d",n);

}

return 0;

}

why does it show wrong answer

1
accept rate: 0%

# include<stdio.h>

int main() { int t,n,temp,i,j,k,l,m,p,q; scanf("%d",&t); for(i=0;i<t;i++) {="" scanf("%d",&n);="" int="" a[n];="" for(j="0;j&lt;n;j++)" {="" scanf("%d",&a[j]);="" }="" scanf("%d",&k);="" m="a[k-1];" for(l="0;l&lt;n;l++)" {="" for(p="0;p&lt;n;p++)" {="" if(a[p]="">a[p+1]) { temp=a[p+1]; a[p+1]=a[p]; a[p]=temp;

            }
}
}
for(q=0;q<n;q++)
{
if(m==a[q]){

printf("%d\n",q+1);
break;
}
}
}
return 0;


}

1
accept rate: 0%

 0 why is it display wromg answer answered 19 Apr '15, 20:17 1 accept rate: 0%
 0 http://www.codechef.com/problems/COINS is the question for which i have written a code http://www.codechef.com/viewsolution/6885244 . Kindly let me know why i am getting wrong answer?? answered 12 May '15, 23:34 1●1●2●2 accept rate: 0%

I don't understand.I am compiling in my system and also in ideone both are giving me same answer. But when I submit it in CodeChef it is showing wrong answer. Why is that happening?

Following is the code for the problem given here http://www.codechef.com/problems/TLG

# include<stdio.h>

int main()

{

int n,si,ti,w=0,l=0,i;

scanf("%d",&n);

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

scanf("%d %d",&si,&ti);

if(si>ti && l<(si-ti))
{
l=si-ti;
w=1;
}
else if(ti>si && l<(ti-si))
{
l=ti-si;
w=2;
}

}
printf("%d %d",w,l);
return 0;


}

Can anyone please tell me what's wrong with it?

311
accept rate: 0%

 0 def repeat(): num=input('Enter number') if num!=42: repeat() print num else: return repeat() Why is it showing wrong answer?? answered 09 Sep '15, 00:36 1 accept rate: 0%

Its giving wrong answer again and again

# include<iomanip>

using namespace std;

int main() {

int x;
float y;

cout<<"\nInput\n";

cin>>x>>y;

cout<<"\nOutput\n";

if ((x<y)&&(x%5==0))
y-=(x+0.50);
cout<<fixed;
cout<<setprecision(2)<<y<<endl;
return 0;


}

it was long but had to cut short it to the above part, still I get a wrong answer.

11
accept rate: 0%

What is wrong in this code? I run this code in codeblocks and it is working fine but getting wrong answer in codechef.

# include<stdio.h>

int main() { int q,r,b=0,m,n,i,j,k,sum=0; scanf("%d",&i); if(i<=100) { while(i!=0) { i--; scanf("%d",&m); scanf("%d",&n); j=m; while(j<=n) { k=j; q=j; while(k>0) { r=k%10; b=(b*10)+r; k=k/10; } if(b==q) { sum=sum+b;

      }
b=0;
j++;
}
printf("%d",sum);
sum=0;


} } return 0; }

0★tushantb
1
accept rate: 0%

# include<stdio.h>

int main() { int t,n,n1,i,j,c,k;

scanf("%d",&t); while(t) {

 c=0;
scanf("%d",&n);
int s[n];
for(k=0;k<n;k++)
scanf("%d",&s[k]);

scanf("%d",&n1);
int f[n1];
for(k=0;k<n1;k++)
scanf("%d",&f[k]);

for(i=0;i<n1;i++)
{
for(j=k;j<n;j++)
{
if(s[j]==f[i])
{
k=j+1;
c++;
break;
}
}
}
if(c==n1)printf("\n Yes");
else printf("\n No");
t--;


} return 0; }

Why am I getting wrong answer for this code?

1
accept rate: 0%

 0 QUESTION : Question ID : ACM14AM4 ISRO is planning to build a landing platform on MARS as a part of MOM. It has selected a small 2-D rectangular region for the same, and every point in the region has a strength associated with it. The landing platform should be in the form of a cross (see definition below for more details) and as strong as possible. The selected 2-D rectangular region has M * N points represented by (x, y), for all 0 <= x < M, 0 <= y < N. Let W[i][j] denote the strength of the point (i, j). We define a cross as follows: It consists of 2 line segments of equal length. The end points of the line segments should coincide with any of the given M * N points. Each of the line segments are at an angle of 45° with both the X & Y axis. Both the line segments intersect exactly at one point, and their centres coincide. (i.e) if the 2 line segments are represented by { (x11, y11), (x12, y12) }, { (x21, y21), (x22, y22) }, then (x11+x12) / 2 = (x21+x22) / 2 and (y11+y12) / 2 = (y21+y22) / 2. The point where the 2 line segments intersect is called the center of the cross. Each line segment of the cross should have a non-zero length. Hence, a single point cannot be considered as a cross.  The strength of a cross is defined as the sum of strengths of all points that lie on it. Your task is to find the cross with maximum strength, which ISRO would like to use as the landing platform. Input The first line contains an integer T, denoting the number of test cases. Then for each test case, the first line contains two integers M and N. Each of the following M lines, contain N space separated integers, where the jth integer on the ith line denotes W[i-1][j-1], for all 1 <= i <= M, 1 <= j <= N. Output For each test case, output a single integer denoting the strength of the maximum-strength cross, on a separate line Constraints T ≤ 100 2 ≤ M ≤ 100 2 ≤ N ≤ 100 -106 ≤ W[i][j] ≤ 106  Example Input: 2 3 3 -1 -1 1 -1 -1 -1 1 -1 -1 2 3 0 1 -2 2 3 1 Output: -1 6 Explanation In the first case, the cross formed by the line segments {(0, 0), (2, 2)} and {(0, 2), (2, 0)} has the maximum strength = 1+(-1)+1+(-1)+(-1) = -1. Note: You cannot choose a cross with 0 strength (not passing through any of the given points) here, because it is given that each line segment of the cross should pass through atleast one of the given points In the second case, the cross formed by the line segments {(0, 0), (1, 1)} and {(0, 1), (1, 0)} has the maximum strength = 0+3+1+2 = 6 SOLUTION : Solution ID :8466199 this code is giving wrong answer. in g++ it is working good for all cases i thoghthmay be possible. how can i correct it. answered 09 Oct '15, 21:12 1 accept rate: 0%

# include<stdio.h>

int main() { int x; float y=20000.00; printf("input\n "); scanf("%d",&x); if((x%5)!= 0) printf("\n\nOutput\n %2f ",y); else { if(x>=y) printf("\n\nOutput\n %2f",y); else { x=x+0.50; y=y-x; printf("\n\nOutput\n %2f",y); } } return 0; }

in this ATM code i am getting wrong answer even if the logic is correct!

0★sam2698
1
accept rate: 0%

GETTING WA :/

# include <iostream>

using namespace std;

int main() { int T,i=0,j,mid,c,k,flag; char str[100][1000]; cin>>T;

if(T>101 || T==0)
return 0;

while(i<T)
{
cin>>str[i];
i++;
}

i=0;
while(i<T)
{
for(j=0;str[i][j]!='\0';++j);
if(j<2 || j>1000)
return 0;

if(j%2==0)
{
mid=j/2;
for(k=0;k<mid;++k)
{   flag=0;
for(c=mid;c<j;++c)
{
if(str[i][c]==str[i][k])
{
str[i][c]='0';
flag=1;
}
}
if(flag==0)
{
cout<<"NO"<<endl;
break;
}

}
if(flag==1)
cout<<"YES"<<endl;
}
else
{
mid=j/2;
for(k=0;k<mid-1;++k)
{   flag=0;
for(c=mid+1;c<j;++c)
{
if(str[i][c]==str[i][k])
{
str[i][c]='0';
flag=1;
}
}
if(flag==0)
{
cout<<"NO"<<endl;
break;
}

}
if(flag==1)
cout<<"YES"<<endl;
}
i++;
}
return 0;


}

1
accept rate: 0%

# include<iostream>

using namespace std; int main() { int t,i,a[100];

int j=1,f=1;
cout<<"enter the no. of values you want to enter"<<endl;
cin>>t;
if(t<=100){

cout<<"enter the values in list"<<endl;
for(i=0;i<t;i++)
cin>>a[i];

for(i=0;i<t;i++)
{
while(j<=a[i])
{
f=f*j;
j++;
}
cout<<"\nthe factorial of given no. is"<<endl<<f;


} }}

why I am getting wrong answer? :(

1
accept rate: 0%

# include<stdio.h>

int main() { int i,j,t,p,n,max,count; int a[101]={0}; int ar[101]={0}; scanf("%d",&t); while(t--) { scanf("%d",&n); for(i=0;i<n;i++) scanf("%d",&a[i]); for(i=0;i<n;i++) { count=0; for(j=0;j<n;j++) { if(a[i]==a[j]) count++; } ar[i]=count; } max=ar[0]; for(i=1;i<n;i++) { if(max<ar[i]) max=ar[i]; } for(i=0;i<n;i++) { if(ar[i]==max) { break; } } p=a[i]; printf("%d %d\n",p,max);

}

return 0;


}

1
accept rate: 0%

why is it showing wrong answer?

(31 Oct '15, 23:36)
 0 why i am getting wrong answer?? I am getting right answer in eclipse ide import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; class SGARDEN { private static String[] s; private static HashMap hm; private static long[] a; private static ArrayList a1; public static void main(String args[]) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); a1 = new ArrayList(); for (int i = 0; i < t; i++) { int n = Integer.parseInt(br.readLine()); a = new long[n]; s = br.readLine().split(" "); hm = new HashMap(); for (int j = 1; j <= s.length; j++) { hm.put(j, Integer.parseInt(s[j - 1])); } for (int j = 1; j <= s.length; j++) { a[j - 1] = solve(j, j); } // System.out.println(Arrays.toString(a)); a1.add((int) (lcm(a) % (10 ^ 9 + 7))); } for (int m : a1) { System.out.println(m); } } private static int solve(int j, int want) { // TODO Auto-generated method stub if (hm.get(j) == want) { return 1; } return solve(hm.get(j), want) + 1; } private static long lcm(long a, long b) { return a * (b / gcd(a, b)); } private static long lcm(long[] input) { long result = input[0]; for (int i = 1; i < input.length; i++) result = lcm(result, input[i]); return result; } private static long gcd(long a, long b) { while (b > 0) { long temp = b; b = a % b; // % is remainder a = temp; } return a; } private static long gcd(long[] input) { long result = input[0]; for (int i = 1; i < input.length; i++) result = gcd(result, input[i]); return result; }  } answered 02 Nov '15, 15:11 0★sesy 1 accept rate: 0%

# include <stdio.h>

int main(void) { int k,s,n,t,y; scanf("%d",&t); for(y=1;y<=t;y++) { scanf("%d",&n);
s=1; for(k=1;k<=n;k++) { s=s*k; } printf("%d\n",s); } return 0; }

why am i getting wrong answer for this question?

1★manvir21
1
accept rate: 0%

 0 print everything what you asked and specially take care of separators(like new line character or space), also do not print anything except you have asked.(for example don't print like "how many num you want to enter"). so you will not get Wrong ans except error in logic. answered 11 Dec '15, 14:35 56●3 accept rate: 30%
 0 A WRONG ANSWER, REASONS and POSSIBLE DEBUGGING :- Wrong function :- The most common reason for a wrong answer is usage of a wrong function. For example, if the problem wants you to add 3 integers but you have subtracted them, WRONG ANSWER! Input-OutPut Format :- The output should be carefully formatted as chef wants everything neat and clean. Maximum of the answers are to be displayed with "\n" a new line and some require inputs require good spacing. Logical Errors :- Well grab a 11th standard book and see what a logical error is and how it can't be detected by the compiler. Making it a horrible error altogether.  That is all folks!! HAPPY CODING!!  answered 12 Dec '15, 09:50 1 accept rate: 0%

# include<stdio.h>

int main() { int t,i,flag=0; char a[1000]; scanf("%d",&t); while(t--) { scanf("%s",a); for(i=0;i<1000;i++) { if(a[i]=='I') {printf("INDIAN"); flag=1; break; }} for(i=0;i<1000;i++) { if(a[i]=='Y') {printf("NOT INDIAN"); flag=1; break; }} if(flag==0) printf("NOT SURE"); }return 0;} this code gives perfectly right answers iam still getting wrong ans can anyone point out my mistake

This answer is marked "community wiki".

1
accept rate: 0%

# include <iostream>

using namespace std;

int main() { int w; float i,f; cin>>w>>i; if((w%5==0)&&(i>w)){ f=i-w-0.50; cout<<f; } else cout<<i; return 0; }

i'm getting a wrong answer in the ATM question and not allowed to ask a question, can anyone help me with this?

1
accept rate: 0%

 0 Anyone tell me plz whats wrong in this? https://www.codechef.com/viewsolution/9360275 answered 09 Feb '16, 14:58 1 accept rate: 0%

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; }

0★aky28
1
accept rate: 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

1
accept rate: 0%

 0 #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<
 0 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  answered 29 Apr '16, 12:12 1 accept rate: 0%
 0 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. answered 30 Apr '16, 15:00 1 accept rate: 0%
 0 thanks you friend answered 01 May '16, 16:48 1 accept rate: 0%

# include<iostream>

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??

1
accept rate: 0%

# include <string>

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?

111
accept rate: 0%

https://www.codechef.com/problems/HS08TEST

Why am I getting a wrong answer?

# include<iomanip>

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"; }

433
accept rate: 0%

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;


}

1
accept rate: 0%

# 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&lt;n;i++)" {="" m="100000000;" if(a[i]="=48)" {="" for(j="0;j&lt;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

2★tiwari9
1
accept rate: 0%

# 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 ??

1
accept rate: 0%

# include<iostream>

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?

1
accept rate: 0%

 0 Check this code for this problem - Ice Cream Problem Working perfectly for sample example - My Solution answered 21 Aug '16, 12:18 3★kama7 1 accept rate: 0%
 0 why i get wrong answer answered 02 Sep '16, 12:50 1★champrg 1 accept rate: 0%

# 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???

0★shuvajit
1
accept rate: 0%

# 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 ?

0★vddesai
1
accept rate: 0%

 0 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. answered 22 Sep '16, 09:30 1 accept rate: 0%

I am able to get all the answers for the sample inputs given in the problem. But still I get "Wrong answer". my problem code is :: CHEFKEY and my answer code is below .

/*
-----   Kiamottullah   -----
(20/ 10/ 2016)
All code is written by me .
You can allways use this code for
Learning context . keep learning


*/

# include <vector>

using namespace std;

class Pair{ private : long long int X; long long int Y;

public :
Pair(int x, int y){
X = x;
Y = y;       // constructor
}
// prototypes of this class
int getX (){
return X;
}
int getY (){
return Y;
}
void show (){
cout << getX() << " " << getY() << endl;
}


};

class Testcase{ private : int N; // height int M; // width long long int C; // number of colours

    vector <Pair> Pairs;    // it's pairs

public :
Testcase (int n, int m, int c){
N = n;
M = m;      // constructor
C = c;
calculatePairs();
}

// prototypes of this class
int getN (){
return N;
}
int getM (){
return M;
}
int getC (){
return C;
}

void calculatePairs (){
// is all color (C) fit in (n*m) display
if((N * M) >= C){

// firstly push two pairs (1, C) and (C, 1)
int x = 1, y = C;
if(isFit(x, y)){
Pairs.push_back(Pair(x, y));
}
x = C, y = 1;
if(isFit(x, y)){
Pairs.push_back(Pair(x, y));
}
// checking all the pairs from 2 to C/2
int hulf = C/2;
for(int i = 2; i <= hulf; i++){
for(int j = 2; j <= C/i; j++){
if(isPair(i, j)){
if(isFit(i, j)){
Pairs.push_back(Pair(i, j));
}
}
}
}
}else {
// so if all color can't drawble
// Pair size will be 0
}
}
void showPairs (){
int s = Pairs.size();   // this function show all the Pairs
for(int i = 0;i < s; i++){  // of C ... one by one
Pairs[i].show();
}
}
bool isFit (int x, int y){
if(((x <= N) && (y <= M))){
return true;        // this function check whether
}else {         // A pair (rect) fit into display (n*m)
return false;
}
}
int getPairsLength (){
return Pairs.size();    // this function return the number of
}                           // Pairs in Pairs vector .

bool isPair (int x, int y){
if ((x * y) == C){      // this function return true if (x*y) == C
return true;        // else return false that's it ((x*y) != C)
}else {
return false;
}
}


};

int main() { // number of test case; int T;

// get input of number of test case
cin >> T;

// make an vector of size T;
vector <Testcase> cases;

for(int i = 0; i < T; i++){         // while (i < T) take input of
int n, m, c;                // (n, m, c) for each testcase
cin >> n >> m >> c;         // then push them in cases
cases.push_back(Testcase(n, m, c)); // vector
}

for(int i = 0; i < cases.size(); i++){  // for each testcase tc
Testcase tc = cases[i];         // cout the length of Pairs
cout << tc.getPairsLength() << endl;
}
return 0;


}

1
accept rate: 0%

 0 One of the best way to handle the wrong ans type problems is that to generate random input by your's side and then by computer side(By taking random inputs using rand() function in C or C++. It will make you to think more and you will definitely crack the crack the code ASAP.. answered 20 Oct '16, 10:37 2.8k●1●4●19 accept rate: 16%

# include<iostream>

using namespace std; int main() { short t,e; long m; int k,n,i,j,key,marks; cin>>t; int a[10000]={0}; int arr[10001][4]={0}; for(;t>0;t--) { cin>>n>>k>>e>>m; for(j=0;j<n;j++) {="" for(i="0;i&lt;e;i++)" {="" if(j="=n-1&amp;&amp;i==e-1)" break;="" else="" {="" cin="">>arr[j][i]; a[j]+=arr[j][i]; } }

    }

for(i=1; i<n-1; i++)
{
key = a[i];
j = i-1;
while(j>=0 && key>a[j])
{
a[j+1] = a[j];
j--;
}
a[j+1] = key;
}

marks=(a[k-1]+1)-a[n-1];
if(marks<=m)
if(marks>0)
cout<<marks;
else
cout<<"0";
else
cout<<"Impossible ";

}
return 0;


}

1
accept rate: 0%

 0 For the problem- Chef Under Pressure, in the subtask 1, out of 10 tasks, it is showing wrong answer for task 0, rest all are coming correct. I checked for possible corner cases that i might have missed, but couldn't find anything. Please tell me what is task 0 and its output, so that i can modify my code. Thanks answered 29 Oct '16, 15:48 1 accept rate: 0%

# include <stdlib.h>

char a[25]; int top=-1; void push(char symbol) {

a[++top]=symbol;


} char pop() {

char item;
item=a[top--];
return(item);


} int precd(char op) {

int r;
switch(op)
{

case'^':r=3; break;
case'*':
case'/':
case'%':r=2; break;
case'+':
case'-':
case'(':r=0; break;
case'#':r=-1;
break;
}
return(r);


} void infix_postfix(char infix[],char postfix[]) {

int i,p=0;
char symbol,item;
push('#');
for(i=0;infix[i]!= '\0';i++)
{

symbol=infix[i];
switch(symbol)
{

case '(':push(symbol);
break;
case ')':item=pop();
while(item!= '(')
{

postfix[p++]=item;
item=pop();
}
break;
case'+':
case'-':
case'*':
case'/':
case'%':
while(precd(a[top])>=precd(symbol));
{

item=pop();
postfix[p++]=item;
}
push(symbol);
break;
default  : postfix[p++]=symbol;
break;
}
}
while(top>0)
{

item=pop();
postfix[p++]=item;
}
postfix[p]= '\0';


} int main() { char infix[25],postfix[25];

printf("enter infix expression");
scanf("%s",infix);
infix_postfix(infix,postfix);
printf("\npostfix expression:%s\n\n\t",postfix);
return 0;


}

This answer is marked "community wiki".

0★shafiq77
1
accept rate: 0%

# include <iostream>

using namespace std; int main() { long long int t,n1,n2,k,l; cin>>t; for (int i=0;i<t;i++) {="" cin="">>n1>>n2; k=n1; l=n2; while(n1 != n2) { if(n1>n2) n1-=n2; else n2-=n1; } cout<<n1<<" "<<(k*l)/n1<<endl; } return 0; }

can someone help me, trying to submit this code but getting wrong answer.Tried another questions many time still not getting it right.This code displays hcf and lcm of two given numbers. Is there any role of constraints provided? or some specific way to output the answer? i'm a beginner please help.

1
accept rate: 0%

u dont need to use long long int for it.try this code.it is similar to ur code

# include <iostream>

using namespace std;

int main() { int t,n1,n2; cin>>t; while(t--){ cin>>n1>>n2; int x=n1,y=n2; while(x!=y){ if(x>y) x-=y; else y-=x; } cout<<x<<endl<<n1*n2/x<<endl; } return 0;

1
accept rate: 0%

 0 I FORGOT A } AFTER THE RETURN 0;. ADD THAT ALSO answered 14 Dec '16, 22:35 1 accept rate: 0% HOPE IT WAS USEFUL.. (14 Dec '16, 22:36)

Hi, i allways get wrong answer in my codes, even tho im getting the correct answer in various tests.

can someone help me?

this is an example: (Using C)

# include <stdlib.h>

int main() { int maxA,maxB,i,n,A[10000],B[10000],C[10000],D[10000],sum_A=0,sum_B=0; scanf("%d",&n); for (i=0;i<n;i++) {="" scanf("%d",&a[i]);="" scanf("%d",&b[i]);="" c[i]="A[i]-B[i];" d[i]="B[i]-A[i];" sum_a+="A[i];" sum_b+="B[i];" maxa="C[i];" maxb="D[i];" }="" for="" (i="1;i&lt;n;i++)" {="" if="" (c[i]="">C[(i-1)] && C[i]>maxA) { maxA=C[i]; } else if (C[(i-1)]>C[i] && C[(i-1)]>maxA) { maxA=C[(i-1)]; } if (D[i]>D[(i-1)] && D[i]>maxB) { maxB=D[i];

}
else if (D[(i-1)]>D[i] && D[(i-1)]>maxB)
{
maxB=D[(i-1)];
}


}

if (maxA>maxB) { printf("%d %d \n",1,maxA); } else { printf("%d %d \n",2,maxB); } return 0; }

1
accept rate: 0%

Contest Code: Practice Problem code: NUMGAME2 My solution:

# define slld(x) scanf("%lld",&x)

using namespace std; long long int t; int isprime (long long int); int main() { long long int n,x,k,q; slld(t); while(t--) { k=0; slld(n); q=n-1; while(q>=1) { if((q==1||isprime(q))&&(n-q)>0) { n-=q; k++; q=n; continue; } q--; } if(k%2==0) printf("ALICE\n"); else printf("BOB\n"); } return 0; } int isprime( long long int N) { if(N<2 || (!(N&1) && N!=2)) return 0; for(int i=3; i*i<=N; i+=2){ if(!(N%i)) return 0; } return 1; }

Plz help to debug my code.

1
accept rate: 0%

 0 it show wrong ans of matrix transformation answered 31 Jan '17, 23:47 1 accept rate: 0%

# include <iostream>

using namespace std;

int main(){ int t=0,n=0,i=1,j=0,ans=1 ; cin >> t ; while(i<=t){ cin >> n ; for(j=n;j>=1;j--){ ans *=j ; } cout << ans << endl; ans = 1; i++ ; } return 0; }

THIS IS SHOWING WRONG ANSWER . WHAT IS THE PROBLEM?

2★eshan292
333
accept rate: 0%

Plz give a link to the Q you are solving.

(11 Feb '17, 18:19)
 0 answered 11 Feb '17, 18:32 2★eshan292 33●3 accept rate: 0%

# include <iostream>

using namespace std ;

int main(){ int i=1,ans,p1,p2,n,lead=0; cin >> n; while(i<=n){ cin >> p1 >> p2 ; lead = lead + p1-p2 ; i++ ; } if(lead>0){ cout << "1" << " " << lead << endl; } else{ ans= lead * (-1) ; cout << "2" << " " << ans << endl; } return 0; }

why is this giving wrong answer? the url for this problem is https://www.codechef.com/problems/TLG

2★eshan292
333
accept rate: 0%

# include <iostream>

using namespace std ;

int main(){ int i=1,ans,p1,p2,n,lead=0; cin >> n; while(i<=n){ cin >> p1 >> p2 ; lead = lead + p1-p2 ; i++ ; } if(lead>0){ cout << "1" << " " << lead << endl; } else{ ans= lead * (-1) ; cout << "2" << " " << ans << endl; } return 0; }

why am i getting wrong answer? https://www.codechef.com/problems/TLG

2★eshan292
333
accept rate: 0%

i have some more doubts but i cant ask question due to insufficient karma points so please upvote me

(02 Apr '17, 22:52) 2★
 0 I think you misinterpreted the Q. You have to find the MAXIMUM difference in scores, and the player with the lead wins. In your case, "lead = lead + p1-p2 " is taking into account the previous lead/lead in previous round, while the example clearly showed this is not the case. I advice, please give another attempt in understanding the Q, and if you're still facing problem, look at its solution here answered 12 Feb '17, 22:01 15.5k●1●20●66 accept rate: 18%
 0 Hi. I am using System.out.println in java to print my answer. Would it cause new line trouble, giving WA? All my answers seem correct with given test cases and few more that I generated by my self. answered 19 Feb '17, 00:42 1 accept rate: 0%

# include <iostream>

using namespace std;

int main() { int t,n,i=0,j=0,a,b,c=0,sum=0,d=0,ctr=0,e,temp ; cin >> t ; while(i<t){ cin="">> n ; int arr[n] ; j=0 ; while(j<n){ cin="">> arr[j] ; j++ ; } c=0 ; sum=0 ; while(c<n){ sum=sum+arr[c] ; c++ ; } for(e=0;e<1;e++){ if(sum!=n*((n+1)/2)){ cout << "no" << endl; temp=1 ; break ; } ctr=0 ; d=0; while(d<n-1){ if(arr[d]+1==arr[d+1]){ ctr+=1 ; } d++ ; } if(ctr==n-1){ cout << "no" << endl ; temp=1 ; break ; } for(b=0;b<n;b++){ for(a=1;a<n;a++){ if(arr[b]==arr[a] && b!=a){ cout << "no" << endl; temp=1; break ; } } if(temp==1){ break; }

    }
}
if(temp!=1){
cout << "yes" << endl;
}
i++ ;
}
return 0;


} why am i getting wrong answer? https://www.codechef.com/problems/KOL16J/-->url for the problem

2★eshan292
333
accept rate: 0%

i have some more doubts but i cant ask question due to insufficient karma points so please upvote me

(02 Apr '17, 22:52) 2★

this is code of life,the universe and everything.

# include<stdio.h>

int main() { int a;

while(1) { scanf("%d\n",&a); if(a==42) break; } return 0; }

0★crearex
1
accept rate: 0%

You are printing nothing dear. The Q asks you to print the number entered on a new line UNTIL 42 is entered. Add a print statement after break statement and it will be fine. :)

(01 Mar '17, 20:36)
 0 Why is my program getting wrong answer? import java.util.*; class pattern { public static void main(String argsp[]){ int q; Scanner in=new Scanner(System.in); int a,b,j,c,d; q=in.nextInt(); for(int i=1;i<=q;i++){ a=in.nextInt(); b=in.nextInt(); if(a<1||b<1||a==b) System.out.println("No"); else if(a==(b+2)||a==(b-2)) System.out.println("Yes"); else { j=(a-1)/2; c=2j+1; d=2j+2; if((c==a&&d==b)||(c==b&&d==a)) System.out.println("Yes"); else System.out.println("No"); } } } } answered 02 Apr '17, 16:00 0★ammar0 1 accept rate: 0%
 0 def remove_dot(this_list,value): while value in this_list: this_list.remove(value) def check(list2): if(list2==[]): return "Valid" elif(list2[0]=='T' or list2[len(list2)-1]=='H'): return "Invalid" else : count=0 for i in range(0,len(list2)-1,2): if(list2[i] is 'H' and list2[i+1] is 'T'): count+=1 if((count*2) is len(list2)): return "Valid" else : return "Invalid" R=int(input()) L=[] str=[] dot='.' ans=[] for i in range(0,R): L.append(int(input())) #for j in range(0,L[i]): value=input() list=[] list[:0]=value remove_dot(list,dot) ans.append(check(list)) for i in range(0,R): print(ans[i]) This is my python code i run in my machine it gives me right output but when i submit in SmackDown contest it tells wrong answer i am trying from 2 days answered 24 May '17, 12:46 1 accept rate: 0%

beginners first problem answer is getting wrong...please tell me where am I wrong?

# include<string.h>

int main() { int i,j,t,s,m; scanf("%d",&t); for(i=0;i<t;i++) { s=0; m=0; char str[100]; scanf("%s",str); for(j=0;str[j]!='\0';j++) {if(str[j]=='s') s+=1; else if(str[j]=='m') m+=1; } for(j=0;j!=(strlen(str)-1);j++) { if(str[j]=='s'&&str[j+1]=='m') { s-=1; str[j]='a';} else if(str[j]=='m'&&str[j+1]=='s') { s-=1; str[j+1]='a'; }

} if(m>s) printf("mongooses\n"); else if(s>m) printf("snakes\n"); else printf("tie\n");

} return 0; }

0★nsb94
1
accept rate: 0%

 0 https://discuss.codechef.com/questions/7640/why-do-i-get-wrong-answer/64059 there are a lot more cases which are hidden and sample cases are not the only ones otherwise there would be no point in submitting you could check them yourself right !! answered 02 Jun '17, 22:54 5★soheb17 60●2 accept rate: 0% there are a lot more cases which are hidden and sample cases are not the only ones otherwise there would be no point in submitting you could check them yourself right !! (02 Jun '17, 22:53) soheb175★
 0 Nick is now a well settled person. Impressed by the coding skills of Nick, N girls wish to marry him. Nick will consider marriage proposals of only those girls who have some special qualities. Qualities are represented by positive non-zero integers. Nick has a list of M qualities which he wants in a girl. He can also consider those girls who have some extra qualities, provided they have at least all those qualities which Nick wants. Find how many girls' proposal will Nick consider. Input: First line contains the integer M, denoting the number of qualities which Nick wants. Next line contains M single space separated distinct integers. Third line contains an integer N, denoting the number of girls. Next follow N lines, ith line contains few single-space separated distinct integers, denoting the qualities of the ith girl. Output: Print the number of girls, whose proposals will be considered by Nick. Constraints: 1 ≤ M ≤ 100 1 ≤ N ≤ 9 x 103 1 ≤ Maximum no. of qualities possessed by girls ≤ 1000. Qualities are positive non-zero integers such that 1 ≤ Quality ≤ 104 Subtask 1: ( 30 points ) 1 ≤ M ≤ 10 1 ≤ N ≤ 100 1 ≤ Maximum no. of qualities possessed by girls ≤ 100. Qualities are positive non-zero integers such that 1 ≤ Quality ≤ 1000 Subtask 2: ( 70 points ) Original constraints Sample Input: 5 1 2 3 4 5 3 1 2 3 4 5 6 1 2 3 4 5 1 2 3 4 Sample Output: 2 can any one ans me? answered 05 Sep '17, 23:42 1 accept rate: 0%
 0 Nick is now a well settled person. Impressed by the coding skills of Nick, N girls wish to marry him. Nick will consider marriage proposals of only those girls who have some special qualities. Qualities are represented by positive non-zero integers. Nick has a list of M qualities which he wants in a girl. He can also consider those girls who have some extra qualities, provided they have at least all those qualities which Nick wants. Find how many girls' proposal will Nick consider. Input: First line contains the integer M, denoting the number of qualities which Nick wants. Next line contains M single space separated distinct integers. Third line contains an integer N, denoting the number of girls. Next follow N lines, ith line contains few single-space separated distinct integers, denoting the qualities of the ith girl. Output: Print the number of girls, whose proposals will be considered by Nick. Constraints: 1 ≤ M ≤ 100 1 ≤ N ≤ 9 x 103 1 ≤ Maximum no. of qualities possessed by girls ≤ 1000. Qualities are positive non-zero integers such that 1 ≤ Quality ≤ 104 Subtask 1: ( 30 points ) 1 ≤ M ≤ 10 1 ≤ N ≤ 100 1 ≤ Maximum no. of qualities possessed by girls ≤ 100. Qualities are positive non-zero integers such that 1 ≤ Quality ≤ 1000 Subtask 2: ( 70 points ) Original constraints Sample Input: 5 1 2 3 4 5 3 1 2 3 4 5 6 1 2 3 4 5 1 2 3 4 Sample Output: 2 can any one ans me? answered 05 Sep '17, 23:42 1 accept rate: 0%
 0 Nick is now a well settled person. Impressed by the coding skills of Nick, N girls wish to marry him. Nick will consider marriage proposals of only those girls who have some special qualities. Qualities are represented by positive non-zero integers. Nick has a list of M qualities which he wants in a girl. He can also consider those girls who have some extra qualities, provided they have at least all those qualities which Nick wants. Find how many girls' proposal will Nick consider. Input: First line contains the integer M, denoting the number of qualities which Nick wants. Next line contains M single space separated distinct integers. Third line contains an integer N, denoting the number of girls. Next follow N lines, ith line contains few single-space separated distinct integers, denoting the qualities of the ith girl. Output: Print the number of girls, whose proposals will be considered by Nick. Constraints: 1 ≤ M ≤ 100 1 ≤ N ≤ 9 x 103 1 ≤ Maximum no. of qualities possessed by girls ≤ 1000. Qualities are positive non-zero integers such that 1 ≤ Quality ≤ 104 Subtask 1: ( 30 points ) 1 ≤ M ≤ 10 1 ≤ N ≤ 100 1 ≤ Maximum no. of qualities possessed by girls ≤ 100. Qualities are positive non-zero integers such that 1 ≤ Quality ≤ 1000 Subtask 2: ( 70 points ) Original constraints Sample Input: 5 1 2 3 4 5 3 1 2 3 4 5 6 1 2 3 4 5 1 2 3 4 Sample Output: 2 can any one ans me? answered 05 Sep '17, 23:42 1 accept rate: 0%
 0 This is my code https://www.codechef.com/viewsolution/15941757 In CodeChef IDE My code run properly and give the right output for the given inputs. but at the submission time it show me WRONG ANSWER!!! message. What is problem with my Code??? answered 23 Oct '17, 10:57 1 accept rate: 0%
 0 import java.util.Scanner; public class A1 { public static void main(String args[]){ Scanner input=new Scanner(System.in); int t=input.nextInt(); int a[]=new int[t]; for(int i=0;i
 0 For Practice Survive import java.util.; import java.lang.; import java.io.; / Name of the class has to be "Main" only if the class is public. / class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner sx=new Scanner(System.in); int t=sx.nextInt(); if(t<=100) { for(int i=0;i

# include<iostream>

using namespace std; int main() { long int n,m,diff; cin>>n>>m; diff=n-m; cout<<endl;

if(diff>=0)
{

if((diff%2)==0)
{
diff+=1;
}
else
{
diff-=1;
}
cout<<diff;


} else return 0; } whats the prblem in above code???

1
accept rate: 0%

# include <bits stdc++.h="">

using namespace std;

bool mem[122][1000002]; bool gop = false; int N; vector<int> ps; vector<int> ans; void dfs(int dx, int sam, int bef, string ss) { if (sam + bef > N || gop) { return; } if (sam + bef == N && dx>=ss.length()) { for (auto v : ps) { ans.push_back(v); } gop = true; return; } if (mem[dx][sam + bef] != 0) { return; } if (sam + bef > 0) { mem[dx][bef + sam] = 1; } if (dx >= ss.length()) { return; } int nev = 0; for (int i = dx;i < dx + 7 && i<ss.length();i++) {="" nev="nev" *="" (int)10="" +="" (int)(ss[i]="" -="" '0');="" if="" (nev=""> N) { return; } ps.push_back(dx); dfs(i + 1, sam + bef, nev, ss); ps.pop_back(); } }

int main() { int test;cin >> test; while (test--) { gop = false;ps.clear();ans.clear(); memset(mem, false, sizeof mem); string ss;cin >> ss; cin >> N; dfs(0, 0, 0, ss); string rol;rol.resize(ans.size() - 1 + ss.length()); reverse(ans.begin(), ans.end()); ans.pop_back(); reverse(ans.begin(), ans.end()); for (int z = 0, j = 0, k = 0;z < rol.length();z++) { if (j < ss.length() && (k >= ans.size() || j < ans[k])) { rol[z] = ss[j]; j++; } else if (k < ans.size()) { rol[z] = '+'; k++; } } cout << rol << endl; } return 0; }

1
accept rate: 0%

 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×1,070
×214

question asked: 22 Mar '13, 16:31

question was seen: 45,500 times

last updated: 23 Sep '18, 00:59