rafiullah007's blog

By rafiullah007, history, 18 months ago, In English

include 222483443

using namespace std; ///MD. Rafiullah Al Naim int main(){ long long n; cin >> n;if(n % 2 == 0)cout << n/2 << endl;else cout << -(n+1)/2 << endl;return 0; }486A - Calculating Function

Explaination : Here I have taken a long long x value . Then I have used a logic n%2==0 . Because if we take a value 4 then the mod of 4 will become 0 so we will do n/2 and get the result 2 . Which match our first output. And if it doesn't then we used a logic which is -(n+1)/2 . If we put value 5 over here then we get -3 . Which match our 2nd output .

Thank You . Name : MD.Rafiullah AL NAim (University Of Asia Pacific)

Full text and comments »

  • Vote: I like it
  • -2
  • Vote: I do not like it