当前位置:网站首页>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 turn off system protection in Win11?How to turn off the system protection restore function?
- 《MySQL入门很轻松》第4章:数据表中存放的数据类型
- 【毕业设计】 基于Stm32的家庭智能监控系统 - 单片机 图像识别 人体检测 AI
- MATLB|和她跌宕起伏最终到达人生之峰【浪漫旅途】
- labelme标注的json标签转txt格式
- Mysql database ALTER basic operations
- WPF DataGrid 使用数据模板
- 《痞子衡嵌入式半月刊》 第 60 期
- 03|流程控制
- 数据库的备份与恢复「建议收藏」
猜你喜欢

快速响应性智能型/智能响应性聚乙二醇纳米/还原响应型水凝胶的研究与制备

deepstream学习笔记(三):deepstream-imagedata-multistream解析与接入适配yolov5模型测试

Creo5.0入门教程赠素材

Next.js获取路由参数及styled-jsx 的使用

Project (7) - PolarSeg point cloud semantic segmentation

算法---整数替换(Kotlin)

3.11-程序基本的控制语句 3.12-表达式 3.13-数据类型 3.14-常量/变量 3.15-标识符

今日睡眠质量记录61分

CST Studio Suite 2021 software installation package and installation tutorial

MATLB|和她跌宕起伏最终到达人生之峰【浪漫旅途】
随机推荐
Penetration Testing and Offensive and Defense Confrontation - Vulnerability Scanning & Logic Vulnerability (Part1)
dlopen failed: library "libtaml.so" not found
游泳馆系统次卡的设置有哪些细节?
Creo5.0入门教程赠素材
程序员从佩洛西窜访事件中可以学到什么?
3.4 - 编译与解释 3.5 - 编译过程 3.8 - 文法
deepstream学习笔记(三):deepstream-imagedata-multistream解析与接入适配yolov5模型测试
渗透测试与攻防对抗——漏洞扫描&逻辑漏洞(Part1)
【毕业设计】基于ESP32的在线墨水屏桌面摆件 -物联网 单片机 嵌入式
365 days challenge LeetCode1000 questions - Day 052 Step by step summation to get the minimum value of positive numbers Greedy
无源晶振负载电容值CL匹配方法及说明
Why don't suggest you run in Docker Mysql?
FITC标记生物素(FITC-生物素|CAS:134759-22-1)有哪些知识了?
Prometeus 2.31.0 新特性
天猫全网商品详情封装接口
Stanford CS143 速通PA1教程
【「收藏」Oracle 数据库安装】
const修饰指针的三种情况
02| operator
Redis redisTemplate.execute 执行锁