当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
随机推荐
How to activate the payment function on WeChat official account?
为什么不建议你在 Docker 中跑 Mysql ?
线程的同步与互斥
断开和服务器共享连接的方法「建议收藏」
游泳馆系统次卡的设置有哪些细节?
2022中高级Android面试题汇总来助你通过面试
3.11-程序基本的控制语句 3.12-表达式 3.13-数据类型 3.14-常量/变量 3.15-标识符
微服务【同步和异步通讯详解】第6章
你有对象类,我有结构体,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang结构体(struct)的使用EP06
openEuler 知:abi 检测
错误提示:Syntax error on token “function”, delete this token
CAS:183896-00-6 (Biotin-PEG3-C3-NH2) PEG衍生物
Koa中间件next实现
c语言文件基本操作总结
由生物素参与的D-Biotinol,CAS号:53906-36-8具体特性说明
生物素叠氮化物中的(CAS:1527486-16-3TAMRA-azide-PEG3-Biotin)反应的特点!
Docker interview question 2--get the number of database connections and docker-compose
Are the numbers entered symmetrical?
7. type( )函数——查询数据类型
LSTM-based distributed energy generation prediction (Matlab code implementation)