当前位置:网站首页>OpenJudge NOI 2.1 1749:数字方格
OpenJudge NOI 2.1 1749:数字方格
2022-07-06 07:12:00 【君义_noip】
【题目链接】
【题目考点】
1. 枚举
【解题思路】
用枚举方法求解方程组
- 枚举对象: a 1 , a 2 , a 3 a_1,a_2,a_3 a1,a2,a3
- 枚举范围: 0 ≤ a 1 , a 2 , a 3 ≤ n 0\le a_1, a_2, a_3 \le n 0≤a1,a2,a3≤n
- 枚举条件:
( a 1 + a 2 ) % 2 = 0 (a_1+a_2)\%2 = 0 (a1+a2)%2=0
( a 2 + a 3 ) % 3 = 0 (a_2+a_3)\%3 = 0 (a2+a3)%3=0
( a 1 + a 2 + a 3 ) % 5 = 0 (a_1+a_2+a_3)\%5 = 0 (a1+a2+a3)%5=0
枚举出来符合条件的 a 1 , a 2 , a 3 a_1,a_2,a_3 a1,a2,a3,选择 a 1 + a 2 + a 3 a_1+a_2+a_3 a1+a2+a3最大的那一组。
【题解代码】
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n, mx = 0;//mx:a1+a2+a3的最大值
cin >> n;
for(int a1 = 0; a1 <= n; ++a1)
for(int a2 = 0; a2 <= n; ++a2)
for(int a3 = 0; a3 <= n; ++a3)
{
if((a1+a2)%2 == 0 && (a2+a3)%3 == 0 && (a1+a2+a3)%5 == 0)
mx = max(mx, a1+a2+a3);
}
cout << mx;
return 0;
}
边栏推荐
- Lesson 12 study notes 2022.02.11
- 这个高颜值的开源第三方网易云音乐播放器你值得拥有
- #systemverilog# 可綜合模型的結構總結
- NFT on fingertips | evaluate ambire on G2, and have the opportunity to obtain limited edition collections
- UWA Pipeline 2.2.1 版本更新说明
- leetcode704. 二分查找(查找某个元素,简单,不同写法)
- Applied stochastic process 01: basic concepts of stochastic process
- 呆错图床系统源码图片CDN加速与破解防盗链功能
- leetcode704. Binary search (find an element, simple, different writing)
- 作者已死?AI正用藝術征服人類
猜你喜欢

树莓派串口登录与SSH登录方法

mysql如何合并数据

Hydra common commands

【服务器数据恢复】IBM服务器raid5两块硬盘离线数据恢复案例

Blue Bridge Cup zero Foundation National Championship - day 20

Kubernetes cluster builds ZABBIX monitoring platform

顶测分享:想转行,这些问题一定要考虑清楚!

Raspberry pie 3B update VIM

MPLS experiment

A brief introduction of reverseme in misc in the world of attack and defense
随机推荐
数据仓库建设思维导图
LeetCode Algorithm 2181. Merge nodes between zero
Zhongqing reading news
OpenGL ES 学习初识(1)
MVVM of WPF
Chrome view page FPS
The author is dead? AI is conquering mankind with art
Prefix and array series
RichView TRVStyle 模板样式的设置与使用
UWA Pipeline 2.2.1 版本更新说明
LeetCode 78:子集
开源的网易云音乐API项目都是怎么实现的?
SEO学习的最好方式:搜索引擎
Week6 weekly report
C - Inheritance - hidden method
The psychological process from autojs to ice fox intelligent assistance
Raspberry pie 3B update VIM
#systemverilog# 可综合模型的结构总结
Uncaught TypeError: Cannot red propertites of undefined(reading ‘beforeEach‘)解决方案
简单描述 MySQL 中,索引,主键,唯一索引,联合索引 的区别,对数据库的性能有什么影响(从读写两方面)