当前位置:网站首页>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;
}
边栏推荐
- Leetcode 78: subset
- Résumé de la structure du modèle synthétisable
- UDP攻击是什么意思?UDP攻击防范措施
- Missing monitoring: ZABBIX monitors the status of Eureka instance
- 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
- Top test sharing: if you want to change careers, you must consider these issues clearly!
- idea控制台彩色日志
- 前缀和数组系列
- 指尖上的 NFT|在 G2 上评价 Ambire,有机会获得限量版收藏品
- leetcode841. Keys and rooms (medium)
猜你喜欢

Cif10 actual combat (resnet18)

巴比特 | 元宇宙每日必读:中国互联网企业涌入元宇宙的群像:“只有各种求生欲,没有前瞻创新的雄心”...

Visitor tweets about how you can layout the metauniverse

19. Actual memory management of segment page combination

LeetCode 78:子集

Uncaught typeerror: cannot red properties of undefined (reading 'beforeeach') solution

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

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

C - Inheritance - polymorphism - virtual function member (lower)

First knowledge of OpenGL es learning (1)
随机推荐
#systemverilog# 可綜合模型的結構總結
chrome查看页面fps
What is the biggest problem that fresh e-commerce is difficult to do now
Uni app practical project
Simple use of JWT
leetcode704. 二分查找(查找某个元素,简单,不同写法)
【Hot100】739. 每日溫度
Idea console color log
编译,连接 -- 笔记 -2
微信脑力比拼答题小程序_支持流量主带最新题库文件
[daily question] 729 My schedule I
Embed UE4 program into QT interface display
Briefly describe the differences between indexes, primary keys, unique indexes, and joint indexes in mysql, and how they affect the performance of the database (in terms of reading and writing)
Uncaught TypeError: Cannot red propertites of undefined(reading ‘beforeEach‘)解决方案
19. Actual memory management of segment page combination
数据仓库建设思维导图
Project GFS data download
配置树莓派接入网络
将ue4程序嵌入qt界面显示
简单描述 MySQL 中,索引,主键,唯一索引,联合索引 的区别,对数据库的性能有什么影响(从读写两方面)