different ways of Mathematical Plays

Revision en2, by kali.ok, 2016-06-14 16:47:34

in the last contest i have participate there a problem called "Johny Likes Numbers" " 678A - Johny Likes Numbers " as i found the shortest c++ solution was using one line


#include <cstdio> int main() { int n, k; scanf("%d %d",&n, &k); printf("%d\n",(n / k + 1) * k); }

how i can found this short formula to solve mathematical problems i've tried on several problems that had mathematical formula and found it's very hard to get it done can anyone advice me to get more powerful in problems like this ?

Tags math, formula, shortest code, help me

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English kali.ok 2016-06-14 16:47:34 71
en1 English kali.ok 2016-06-14 16:46:23 593 Initial revision (published)