当前位置:网站首页>Openjudge noi 2.1 1749: Digital Square
Openjudge noi 2.1 1749: Digital Square
2022-07-06 07:14:00 【Jun Yi_ noip】
【 Topic link 】
OpenJudge NOI 2.1 1749: Number squares
【 Topic test site 】
1. enumeration
【 Their thinking 】
Solve equations by enumerating
- enumerable object : a 1 , a 2 , a 3 a_1,a_2,a_3 a1,a2,a3
- Enumeration range : 0 ≤ a 1 , a 2 , a 3 ≤ n 0\le a_1, a_2, a_3 \le n 0≤a1,a2,a3≤n
- Enumeration condition :
( 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
Enumerate the qualified a 1 , a 2 , a 3 a_1,a_2,a_3 a1,a2,a3, choice a 1 + a 2 + a 3 a_1+a_2+a_3 a1+a2+a3 The largest group .
【 Solution code 】
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n, mx = 0;//mx:a1+a2+a3 The maximum of
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;
}
边栏推荐
- Raspberry pie 3B update VIM
- Twelve rules for naming variables
- Leetcode35. search the insertion position (simple, find the insertion position, different writing methods)
- OpenJudge NOI 2.1 1749:数字方格
- Cookie Technology & session Technology & ServletContext object
- Embed UE4 program into QT interface display
- Oracle数据库11gr2使用tde透明数据加密报错ora28353,如果运行关闭wallet会报错ora28365,运行打开wallet就报错ora28353无法打开wallet
- L'auteur est mort? Ai utilise l'art pour conquérir l'humanité
- UWA Pipeline 2.2.1 版本更新说明
- Arduino tutorial - Simon games
猜你喜欢

leetcode704. Binary search (find an element, simple, different writing)

Thought map of data warehouse construction

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

Introduction to ros2 installation and basic knowledge

Week6 weekly report

Raspberry pie serial port login and SSH login methods

Twelve rules for naming variables

ROS learning_ Basics

Supporting title of the book from 0 to 1: ctfer's growth road (Zhou Geng)

NFT on fingertips | evaluate ambire on G2, and have the opportunity to obtain limited edition collections
随机推荐
Uncaught TypeError: Cannot red propertites of undefined(reading ‘beforeEach‘)解决方案
Simple use of JWT
C - Inheritance - polymorphism - virtual function member (lower)
(4) Web security | penetration testing | network security web site source code and related analysis
作者已死?AI正用艺术征服人类
可变参数重载时的内存错误
hydra常用命令
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
【线上问题处理】因代码造成mysql表死锁的问题,如何杀掉对应的进程
leetcode704. Binary search (find an element, simple, different writing)
JDBC学习笔记
MVVM of WPF
Yield method of tread
leetcode35. 搜索插入位置(简单,找插入位置,不同写法)
Bio model realizes multi person chat
Cookie技术&Session技术&ServletContext对象
【服务器数据恢复】IBM服务器raid5两块硬盘离线数据恢复案例
Hydra common commands
Uni app third party package configuration network request
Wechat brain competition answer applet_ Support the flow main belt with the latest question bank file