Formulas? What formulas?
You get 510 total EVs to allocate. Every 4 EVs in a single stat you earn nets you 1 additional point in that stat (at level 100). The most EVs you can put into a stat is 255, but since 255 is not evenly divisible by 4, the most you _should_ be putting in a stat is 252. This lets you be the most efficient with your EVs.
EVs are gained after every battle. If your Pokemon would receive EXP from a battle, it will receive all EVs too.
I guess there are formulas when factoring in Power items and PKRS but those are easy to understand, too:
If a Pokemon has PKRS, it doubles EVs gained.
if a Pokemon is holding Macho Brace, it doubles EVs gained. This can be combined with PKRS for a 4x EV gain.
Power items _add four_ EVs to the base given from a Pokemon. This can be combined with PKRS for huge gains in a single stat or you can use it to dual train in two stats
so if I have the Power Anklet (+4 speed) and kill a Starly (which gives 1 Speed EV), I get 5 Speed points (1 + 4). If I have PKRS, I get 10 ([1 + 4] x 2). Note how PKRS is factored AFTER the item.
Say now that I have a Power Lens (+4 spatk) and kill another Starly. I get 1 Speed and 4 Special Attack (1 from Starly, 4 from the item). If I have PKRS, I get 2 Speed and 8 Special Attack (1 x 2, 4 x 2).
The game doesn't keep track of your EVs so you will have to do this yourself with pen and paper.
easy, no?