当前位置:网站首页>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;
}
边栏推荐
- Path analysis model
- leetcode35. 搜索插入位置(简单,找插入位置,不同写法)
- leetcode1020. 飞地的数量(中等)
- ORACLE列转行--某字段按指定分隔符转多行
- Multi attribute object detection on rare aircraft data sets: experimental process using yolov5
- NFT on fingertips | evaluate ambire on G2, and have the opportunity to obtain limited edition collections
- (4) Web security | penetration testing | network security web site source code and related analysis
- #systemverilog# 可綜合模型的結構總結
- Setting and using richview trvstyle template style
- Crawling exercise: Notice of crawling Henan Agricultural University
猜你喜欢

1189. Maximum number of "balloons"

How to find a medical software testing institution? First flight software evaluation is an expert

Cookie Technology & session Technology & ServletContext object

【线上问题处理】因代码造成mysql表死锁的问题,如何杀掉对应的进程

ROS learning_ Basics

Idea console color log

Solution to the problem of breakthrough in OWASP juice shop shooting range

Cif10 actual combat (resnet18)

Raspberry pie serial port login and SSH login methods

Kubernetes cluster builds ZABBIX monitoring platform
随机推荐
可变参数重载时的内存错误
C language_ Double create, pre insert, post insert, traverse, delete
[JDBC] quick start tutorial
Structure summary of SystemVerilog integrable model
JDBC学习笔记
微信公众号无限回调授权系统源码 全网首发
软件测试外包到底要不要去?三年真实外包感受告诉你
杰理之BLE【篇】
Applied stochastic process 01: basic concepts of stochastic process
Detailed explanation | detailed explanation of internal mechanism of industrial robot
Uni app practical project
leetcode841. 钥匙和房间(中等)
Introduction to ros2 installation and basic knowledge
UWA pipeline version 2.2.1 update instructions
[server data recovery] case of offline data recovery of two hard disks of IBM server RAID5
【服务器数据恢复】IBM服务器raid5两块硬盘离线数据恢复案例
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
Configure raspberry pie access network
【JDBC】快速入门教程
首发织梦百度推送插件全自动收录优化seo收录模块