i=1⋃nAi=i=1∑n∣Ai∣−i<j∑∣Ai∩Aj∣+⋯+(−1)n+1∣A1∩⋯∩An∣. 数论容斥 设 f(x) 表示 gcd=x 对答案的贡献, g(x) 表示 gcd=kx 对答案的贡献,则 f(x)=g(x)−f(2x)−f(3x)−⋯.