Click here to Skip to main content
15,920,438 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
for the following codeforces problem Problem - A - Codeforces[^]

My code produces a wrong output on

Test case (5) : 10 7
required a 10-digit-number divisible by 7 .

What I have tried:

int main(){
   
    int n, t;
    cin >> n >> t;
    
    if(n == 1 && t == 10)
        cout << "-1";
    if(t == 10)
        cout << 10 * pow(10,n-2);
    else
        cout << t * pow(10,n-1) << endl ;
    
    return 0;
}

The output from pow(7, 9) is (7e+009)
what does this symbols mean ?
Is this a drawback of pow(,) in C++ or it's me that misused it ?

N.B. I know another solution would be to print zeroes concatenated after the number or output 7777777777 . I want fixation to my solution and discover pow(,) more.
Posted
Updated 2-Nov-18 2:43am
v2
Comments
Richard MacCutchan 2-Nov-18 10:26am    
You need to set the formatting options for the number in your output statement. What you see by default is scientific notation.

1 solution

Your code is a mess and buggy. Use indention and braces to clarify it.

The output is a formatted number and the result of the calculation. Use variables for results and the debugger.
 
Share this answer
 
Comments
Member 13476370 2-Nov-18 8:45am    
Done formatting the code .
I already know what that the output is formatted what I don't know is why does pow(,) return this answer and how can I fix it.
Please clarify your answer .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900