A new approach to the wave function of the universe is suggested. The key idea is to take into account fluctuating number fields and present the wave function in the form of a Euler product. For this purpose we define a p-adic generalization of both classical and quantum gravitational theory. Elements of p-adic differential geometry are described. The action and gravitation field equations over the p-adic number field are investigated. p-adic analogs of some known solutions to the Einstein equations are presented. It follows that in quantum cosmology one should consider summation only over algebraic manifolds. The correspondence principle with the standard approach is considered.