# Getting wrong answer in the problem code:PERMUT2

**URL:** <https://discuss.codechef.com/t/getting-wrong-answer-in-the-problem-code-permut2/72841>\
**Category:** general\
**Created:** [July 22, 2020, 11:15am UTC](https://discuss.codechef.com/t/getting-wrong-answer-in-the-problem-code-permut2/72841 "2020-07-22T11:15:42Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![aneee004](https://discuss.codechef.com/user_avatar/discuss.codechef.com/aneee004/32/222765_2.png) [@aneee004](https://discuss.codechef.com/u/aneee004)\
**Post date:** [July 22, 2020, 11:37am UTC](https://discuss.codechef.com/t/getting-wrong-answer-in-the-problem-code-permut2/72841/4 "2020-07-22T11:37:30Z")

</div>

I am taking about your `orig`. It has n digits. And an `int` can only have 9 digits. So when n \> 10, you have overflow in `orig`.

> [@Simple Trick to Detect Integer Overflow (C/C++)](https://discuss.codechef.com/t/simple-trick-to-detect-integer-overflow-c-c/54373/20):
>
> Interesting - it’s not crashing for me, either. However: [simon@simon-laptop][17:53:24] [~/devel/hackerrank/otherpeoples]\>cat everule1-ftrapv-test.cpp #pragma GCC optimize "trapv" #include\<iostream\> #include\<bits/stdc++.h\> #define ll long long int using namespace std; int main(){ int a,b; cin \>\> a \>\> b; cout\<\<a\<\<" "\<\<b\<\<'\n'; int f=a\*b; cout\<\<f; } [simon@simon-laptop][17:53:32] [~/devel/hackerrank/otherpeoples]\>g++ -std=c++14 everule1-ftrapv-test.cpp …

Add this optimization flag to detects overflows.

---

_[View the full topic](https://discuss.codechef.com/t/getting-wrong-answer-in-the-problem-code-permut2/72841)._
