当前位置:网站首页>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;
}
边栏推荐
- Fast target recognition based on pytorch and fast RCNN
- Raspberry pie 3B update VIM
- The psychological process from autojs to ice fox intelligent assistance
- Embed UE4 program into QT interface display
- PCL实现选框裁剪点云
- 作者已死?AI正用艺术征服人类
- 多线程和并发编程(二)
- Misc of BUU (update from time to time)
- Idea console color log
- ROS learning_ Basics
猜你喜欢

首发织梦百度推送插件全自动收录优化seo收录模块

Thought map of data warehouse construction
![[server data recovery] case of offline data recovery of two hard disks of IBM server RAID5](/img/c3/7a147151b7338cf38ffbea24e8bafd.jpg)
[server data recovery] case of offline data recovery of two hard disks of IBM server RAID5

The best way to learn SEO: search engine

L'auteur est mort? Ai utilise l'art pour conquérir l'humanité

How are the open source Netease cloud music API projects implemented?

这个高颜值的开源第三方网易云音乐播放器你值得拥有

树莓派3B更新vim

19.段页结合的实际内存管理

开源的网易云音乐API项目都是怎么实现的?
随机推荐
Short video, more and more boring?
The difference between get and post request types
Win10 64 bit Mitsubishi PLC software appears oleaut32 DLL access denied
Chrome view page FPS
NFT on fingertips | evaluate ambire on G2, and have the opportunity to obtain limited edition collections
Path analysis model
Uni app third party package configuration network request
Prefix and array series
What is the biggest problem that fresh e-commerce is difficult to do now
(4) Web security | penetration testing | network security web site source code and related analysis
RichView TRVStyle 模板样式的设置与使用
Cif10 actual combat (resnet18)
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
leetcode1020. 飞地的数量(中等)
Huawei equipment configuration ospf-bgp linkage
Structure summary of SystemVerilog integrable model
Misc of BUU (update from time to time)
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
C language_ Double create, pre insert, post insert, traverse, delete
leetcode35. 搜索插入位置(简单,找插入位置,不同写法)