当前位置:网站首页>Solving for the number of mines
Solving for the number of mines
2022-08-10 01:47:00 【-JMY-】
题目描述
In order to ensure that important military bases on the border will not be invaded by the enemy,Our army was buried on the way the enemy army must passx颗地雷,known this
The place to go isn * msquare shape,To let our friendly forces know where there are mines,Our military engineers drew one
Mine distribution map.in this distribution,If there are no mines at a certain point,Then the sum of the bits of the number marked by this point will be one
个偶数;Conversely, if the point has a mine,The sum of the bits of the number marked by this point is an odd number.
Please program it out,How many mines have been planted in the area in total.
比如:There is one below5 * 6mine distribution map,The areas in which the mines are buried are marked with a grey background,shared in this area
10颗地雷.
12 | 35 | 90 | 21 | 1 | 9 |
91 | 3892 | 8749 | 342 | 3421 | 89 |
1881 | 1111 | 39 | 4 | 1 | 34 |
9 | 93 | 34 | 12 | 45 | 0 |
67 | 4 | 34 | 19 | 235 | 32 |
输入
接下来n行,每行有m个整数,The number of markers representing whether there are mines(These numbers are all marked<=9999的整数)
输出
样例输入
5 6 12 35 90 21 1 9 91 3892 8749 342 3421 89 1881 1111 39 4 1 34 9 93 34 12 45 0 67 4 34 19 235 32
样例输出
16
参考代码:
#include<bits/stdc++.h>
using namespace std;
int n,m,a[105][105],s;
int f(int x){
int k=0;
while(x!=0){
k+=x%10;
x/=10;
}
return k%2;
}
int main(){
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)
for(int j=0;j<m;j++){
scanf("%d",&a[i][j]);
if(f(a[i][j])==1)
s++;
}
printf("%d",s);
return 0;
}
边栏推荐
猜你喜欢
随机推荐
Leetcode82. 删除排序链表中的重复元素 II
CAS:851113-28-5 (Biotin-ahx-ahx-tyramine)
[SSH]如何敲一条线
Involved in PEG-Biotin (CAS: 1778736-18-7) Biotin-PEG4-OH is widely used in molecular target detection
Kubernetes 60个为什么
错误提示:Syntax error on token “function”, delete this token
The technical aspects of the byte have been passed, and the salary has been negotiated for 20K*13, but the result is still being brushed. I asked the HR why...
Leetcode83. 删除排序链表中的重复元素
Creo5.0 introductory tutorial free material
【CAS:41994-02-9 |Biotinyl tyramide】生物素基酪氨酰胺价格
c语言指针练习题
3.1 - 程序设计语言 3.2 - 高级语言的特点及引用 3.3 - 静态/动态类型语言
使用C语言实现静态链表
温度响应性纳米水凝胶光子品体/纤维素修饰荧光水凝胶/载脂质体水凝胶的制备方法
【C语言】通讯录《静态内存版本》
Redisson 分布式锁
Web性能测试模型小结
What do you know about FITC-labeled biotin (FITC-biotin|CAS: 134759-22-1)?
How to activate the payment function on WeChat official account?
最高月薪15K,谁有历经千辛万苦的意志,谁就能收获属于自己的成功~