因式分解之后发现,满足条件的x要么是奇数,要么是4的倍数
#include <iostream> #include <stdio.h> #include <algorithm> #include <string> #include <cmath> #define R(x) x = read() #define For(i, j, n) for(int i = j ; i <= n ; ++i) using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } int l, r; int f(int n) { return (n + 1)/2 + n/4; } int main() { R(l);R(r); printf("%d\n", f(r) - f(l - 1)); return 0; }
标签:ch,P9231,平方差,蓝桥,2023,include From: https://www.cnblogs.com/smartljy/p/18120706