当前位置:网站首页>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;
}
边栏推荐
- 19. Actual memory management of segment page combination
- How to configure GUI guide development environment
- 杰理之BLE【篇】
- UDP攻击是什么意思?UDP攻击防范措施
- JDBC learning notes
- C - Inheritance - polymorphism - virtual function member (lower)
- Go learning -- implementing generics based on reflection and empty interfaces
- 顶测分享:想转行,这些问题一定要考虑清楚!
- Short video, more and more boring?
- leetcode704. Binary search (find an element, simple, different writing)
猜你喜欢

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

Go learning --- use reflection to judge whether the value is valid

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

navicat如何导入MySQL脚本

Due to high network costs, arbitrum Odyssey activities are suspended, and nitro release is imminent

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

Multi attribute object detection on rare aircraft data sets: experimental process using yolov5

树莓派串口登录与SSH登录方法

Cookie Technology & session Technology & ServletContext object

首发织梦百度推送插件全自动收录优化seo收录模块
随机推荐
树莓派串口登录与SSH登录方法
leetcode841. Keys and rooms (medium)
[hot100] 739. Température quotidienne
Visitor tweets about how you can layout the metauniverse
微信公众号无限回调授权系统源码 全网首发
BIO模型实现多人聊天
Upgraded wechat tool applet source code for mobile phone detection - supports a variety of main traffic modes
Compile, connect -- notes-2
Due to high network costs, arbitrum Odyssey activities are suspended, and nitro release is imminent
Twelve rules for naming variables
How to configure GUI guide development environment
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
18. Multi level page table and fast table
3. Business and load balancing of high architecture
OpenGL ES 学习初识(1)
Cif10 actual combat (resnet18)
Hydra common commands
win10 64位装三菱PLC软件出现oleaut32.dll拒绝访问
UWA Pipeline 2.2.1 版本更新说明
WPF之MVVM