当前位置:网站首页>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;
}
边栏推荐
- #systemverilog# 可綜合模型的結構總結
- #systemverilog# 可综合模型的结构总结
- How to find a medical software testing institution? First flight software evaluation is an expert
- [some special grammars about C]
- PCL实现选框裁剪点云
- Proteus -- Serial Communication parity flag mode
- Is software testing outsourcing going or not? Three years' real outsourcing experience tells you
- “无聊猿” BAYC 的内忧与外患
- Chrome view page FPS
- leetcode6109. 知道秘密的人数(中等,周赛)
猜你喜欢
Solution to the problem of breakthrough in OWASP juice shop shooting range
Oracle database 11gr2 uses TDE transparent data encryption to report an error ora28353. If you run to close the wallet, you will report an error ora28365. If you run to open the wallet, you will repor
leetcode6109. 知道秘密的人数(中等,周赛)
Twelve rules for naming variables
WPF之MVVM
这个高颜值的开源第三方网易云音乐播放器你值得拥有
Missing monitoring: ZABBIX monitors the status of Eureka instance
3. Business and load balancing of high architecture
漏了监控:Zabbix对Eureka instance状态监控
Babbitt | metauniverse daily must read: the group image of Chinese Internet enterprises pouring into metauniverse: "there are only various survival desires, and there is no ambition for forward-lookin
随机推荐
[server data recovery] case of offline data recovery of two hard disks of IBM server RAID5
Uni app third party package configuration network request
BIO模型实现多人聊天
leetcode1020. Number of enclaves (medium)
19.段页结合的实际内存管理
Huawei equipment configuration ospf-bgp linkage
ROS学习_基础
作者已死?AI正用藝術征服人類
The difference between get and post request types
【每日一题】729. 我的日程安排表 I
C language_ Double create, pre insert, post insert, traverse, delete
LeetCode 78:子集
巴比特 | 元宇宙每日必读:中国互联网企业涌入元宇宙的群像:“只有各种求生欲,没有前瞻创新的雄心”...
从autojs到冰狐智能辅助的心里历程
Week6 weekly report
Cookie Technology & session Technology & ServletContext object
NFT on fingertips | evaluate ambire on G2, and have the opportunity to obtain limited edition collections
UWA pipeline version 2.2.1 update instructions
Blue Bridge Cup zero Foundation National Championship - day 20
First knowledge of OpenGL es learning (1)