evilbuggy's blog

By evilbuggy, history, 7 months ago, In English,
#include <bits/stdc++.h>

using namespace std;

bool overflow(long long int a, long long int b){
    long long int c = a*b;
    cout<<a<<" "<<b<<" "<<c<<" "<<c/a<<" "<<c/b<<endl;
    return (c/b) != a;

int main(){
    long long int a = 847288609443LL; // 3^25
    cout<<overflow(a, a)<<endl;

When I run the above code in my PC I get the following output...

847288609443 847288609443 6048575297968530377 7138742 7138742

But when I run it on codeforces I get the following output....

847288609443 847288609443 6048575297968530377 7138742 847288609443

What could be the problem here? Btw Why c/a and c/b different in codeforces output though a and b have same value?

Please help me out.

Read more »


By evilbuggy, history, 12 months ago, In English,


My first blog post :) Any constructive feedback is welcome.

Read more »

  • Vote: I like it  
  • +34
  • Vote: I do not like it