题面
Nothing’s ever been the same since… that summer with her.
— Shizuku Hoshikawa
Kaori wants to spend the day with Shizuku! However, the zoo is closed, so they are visiting Farmer John’s farm instead.
At Farmer John’s farm, Shizuku counts legs. It is known that only chickens and cows live on the farm; a chicken has legs, while a cow has .
Count how many different configurations of Farmer John’s farm are possible. Two configurations are considered different if they contain either a different number of chickens, a different number of cows, or both.
Note that Farmer John’s farm may contain zero chickens or zero cows.
Input
The first line contains a single integer () — the number of test cases.
The only line of each test case contains a single integer ().
Output
For each test case, output a single integer, the number of different configurations of Farmer John’s farm that are possible.
思路
根据题意列出方程: ,设 为鸡的数量, 为牛的数量
很明显的一个情况, 为奇数的时候,答案必定为
而如果为偶数, 可以从 取到 ,所以方案数量为
代码
#include <bits/stdc++.h>
using namespace std;
int main() { int t; cin >> t; while (t --) { int n; cin >> n;
if (n % 2 != 0) cout << 0 << endl; else cout << n / 4 + 1 << endl; }}