当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
树莓派3B更新vim
How are the open source Netease cloud music API projects implemented?
How to find a medical software testing institution? First flight software evaluation is an expert
SSM learning
idea控制台彩色日志
mysql如何合并数据
杰理之BLE【篇】
What is the biggest problem that fresh e-commerce is difficult to do now
Supporting title of the book from 0 to 1: ctfer's growth road (Zhou Geng)
JDBC learning notes
随机推荐
SSM learning
C language_ Double create, pre insert, post insert, traverse, delete
C - Inheritance - hidden method
Compile, connect -- notes-2
Misc of BUU (update from time to time)
18. Multi level page table and fast table
leetcode59. 螺旋矩阵 II(中等)
The difference between get and post request types
1091: two or three things in childhood (multi instance test)
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
ORACLE列转行--某字段按指定分隔符转多行
A brief introduction of reverseme in misc in the world of attack and defense
Uncaught typeerror: cannot red properties of undefined (reading 'beforeeach') solution
navicat如何导入MySQL脚本
Zhongqing reading news
Cif10 actual combat (resnet18)
Wechat official account infinite callback authorization system source code, launched in the whole network
Solution to the problem of breakthrough in OWASP juice shop shooting range
MVVM of WPF
ROS learning_ Basics