当前位置:网站首页>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;
}
边栏推荐
- Cookie Technology & session Technology & ServletContext object
- 这个高颜值的开源第三方网易云音乐播放器你值得拥有
- Win10 64 bit Mitsubishi PLC software appears oleaut32 DLL access denied
- Thought map of data warehouse construction
- leetcode6109. 知道秘密的人数(中等,周赛)
- 漏了监控: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
- 【Hot100】739. Daily temperature
- After sharing the clone remote project, NPM install reports an error - CB () never called! This is an error with npm itself.
- mysql如何合并数据
猜你喜欢
[advanced software testing step 1] basic knowledge of automated testing
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Blue Bridge Cup zero Foundation National Championship - day 20
UWA Pipeline 2.2.1 版本更新说明
leetcode841. Keys and rooms (medium)
接口自动化测试框架:Pytest+Allure+Excel
巴比特 | 元宇宙每日必读:中国互联网企业涌入元宇宙的群像:“只有各种求生欲,没有前瞻创新的雄心”...
Huawei equipment configuration ospf-bgp linkage
18.多级页表与快表
Configure raspberry pie access network
随机推荐
微信脑力比拼答题小程序_支持流量主带最新题库文件
[advanced software testing step 1] basic knowledge of automated testing
Win10 64 bit Mitsubishi PLC software appears oleaut32 DLL access denied
树莓派3B更新vim
开源的网易云音乐API项目都是怎么实现的?
Twelve rules for naming variables
SSM学习
Missing monitoring: ZABBIX monitors the status of Eureka instance
Proteus -- Serial Communication parity flag mode
Chrome view page FPS
Project GFS data download
leetcode704. Binary search (find an element, simple, different writing)
数据仓库建设思维导图
漏了监控:Zabbix对Eureka instance状态监控
MVVM of WPF
【Hot100】739. 每日温度
Thought map of data warehouse construction
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Raspberry pie serial port login and SSH login methods
Zhongqing reading news