beginner_boy's blog

By beginner_boy, history, 4 years ago, In English

Hello everyone, i want to present a very strange situation that happened with me on problem 1500B. I've tried to solve it by almost 3 hours, and cant figure out why my code was failing on test 11, and so i discovered that for some reason the problem was here:

ll lcm(ll n, ll m){
      return n * (m / __gcd(n, m));
}
...
int n, m;
ll k;
 
scanf("%d %d %lld", &n, &m, &k);
	
ll l = lcm(n, m);

the variable l (lcm value) was given overflow (negative value), but if i change the variable n and m to ll (int64) it works as expected and i got acc. Is it right ? i mean, if i declare n and m as int32, but inside lcm i expect values as int64, this should be converted, and the return should not overflow as well, right ?

Here is my WA submission 111601427, and the accepted 111601468

Can anyone tell me why this is happening ? Thanks in advance.

Full text and comments »

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

By beginner_boy, history, 6 years ago, In English

Hello everyone, i am stuck with the problem 1279 — Graph Coloring which can be solved computing the value $$$K ^ {(n - r)}$$$, where $$$r$$$ is the rank of matrix $$$a$$$, according with this blog, but i cant understand how it works, specifically what's the sense of the matrix $$$a$$$ builded in this code bellow:

snippet

Full text and comments »

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

By beginner_boy, history, 6 years ago, In English

Hello, someone can explain how to solve this problem from today contest in AtCoder?

Full text and comments »

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