思路
这题有着数学解法,但是时间限制与数据范围都很宽松,所以我们可以直接枚举每一个座位,判断其是否是好座位,题目描述好座位:
- 这个座位在第一排。
- 这个座位是这一行最左边或最右边的位置。
- 这个座位的行号 和列号 的乘积的个位数字是 6。
- 满足任意即可
我们转化一下
- 这个座位行数为 1。
- 这个座位列数为 1 或 。
- 这个座位行数乘列数膜 10 等于 6。
- 满足任意即可。
code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e2 + 10;
int n;
int main() {
int t;
cin >> t;
while (t--) {
cin >> n;
int ans = 0; //最终答案(好座位个数)
for (int i = 1 ; i <= n ; i++) {
int x;
cin >> x;
for (int j = 1 ; j <= x ; j++) { //枚举每一个座位
if (i == 1 || j == 1 || j == x || (i * j) % 10 == 6) ans++; //如果是好座位,那么答案++
}
}
cout << ans << "\n"; //输出答案
}
return 0;
}