TOPIC

Wrong Answer (5%).....But why?

Rezaul Karim asked 2 years ago

#include <bits/stdc++.h>
using namespace std;

int main()
{
    long int A,B;
    long long int C=0;
    int N,len1,len2;
    stringstream Str1,Str2;

    cin>>N;
    while(N--)
    {
        cin>>A>>B;

        Str1<<A;
        Str2<<B;
        len1 = Str1.str().size();
        len2 = Str2.str().size();

        if(len2==2)
        {
            C = pow(10,len2)+1;
            C=A%C;

            if(B==C)
                cout<<"encaixa"<<endl;
            else
                cout<<"nao encaixa"<<endl;

        }

        else if(len1>=len2)
        {
            C = pow(10,len2);
            C=A%C;

            if(B==C)
                cout<<"encaixa"<<endl;
            else
                cout<<"nao encaixa"<<endl;
        }

        else
        {
            cout<<"nao encaixa"<<endl;
        }

    }

    return 0;
}

Remember not post solutions. Your post may be reviewed by our moderators.

  • Rezaul Karim replied 2 years ago

    In my CodeBlocks,99 shown that pow(10,2) .......so,I add 1 when len2=2 but I had removed that,and submitted again.......but still this problem"WRONG ANSWER (5%)".

  • feodorv replied 2 years ago

    Can I ask you, why +1 here?

    if(len2==2) { C = pow(10,len2)+1;