The problem to determine the classical and quantum optimal strategies for quantum games rely at the heart of quantum non-locality and its applications to quantum technologies. These optimal strategies are hard to find even in relatively simple scenarios. In this work, we establish a one-to-one connection existing between the problem of calculating the optimal classical strategy of a game and a well-studied problem in mathematics some decades ago, namely to calculate the excess of a matrix. Our findings allow us to find -analytically and without requiring any calculation- both the optimal classical and quantum strategies for infinitely many quantum games for bipartite scenarios having arbitrary large number of settings and outcomes. Classical and quantum values coincide for all inequalities considered, whereas the no-signaling value can be higher in general. As consequence of our findings we are able to calculate the Shannon zero-error capacity for infinitely many graphs.