当前位置:网站首页>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;
}
边栏推荐
- Cif10 actual combat (resnet18)
- Multi attribute object detection on rare aircraft data sets: experimental process using yolov5
- 杰理之BLE【篇】
- CDN acceleration and cracking anti-theft chain function
- Interface automation test framework: pytest+allure+excel
- C - Inheritance - hidden method
- Librosa audio processing tutorial
- Visitor tweets about how you can layout the metauniverse
- Detailed explanation | detailed explanation of internal mechanism of industrial robot
- PCL realizes frame selection and clipping point cloud
猜你喜欢
How to find a medical software testing institution? First flight software evaluation is an expert
Short video, more and more boring?
呆错图床系统源码图片CDN加速与破解防盗链功能
idea控制台彩色日志
“无聊猿” BAYC 的内忧与外患
Visitor tweets about how you can layout the metauniverse
杰理之BLE【篇】
变量的命名规则十二条
【线上问题处理】因代码造成mysql表死锁的问题,如何杀掉对应的进程
C - Inheritance - polymorphism - virtual function member (lower)
随机推荐
杰理之普通透传测试---做数传搭配 APP 通信【篇】
leetcode841. Keys and rooms (medium)
leetcode841. 钥匙和房间(中等)
Interface automation test framework: pytest+allure+excel
作者已死?AI正用艺术征服人类
UDP攻击是什么意思?UDP攻击防范措施
微信公众号无限回调授权系统源码 全网首发
You deserve this high-value open-source third-party Netease cloud music player
Misc of BUU (update from time to time)
Bloom taxonomy
How to find a medical software testing institution? First flight software evaluation is an expert
LeetCode Algorithm 2181. Merge nodes between zero
1189. Maximum number of "balloons"
SSM learning
#systemverilog# 可综合模型的结构总结
Refer to how customer push e-commerce does content operation
软件测试外包到底要不要去?三年真实外包感受告诉你
微信脑力比拼答题小程序_支持流量主带最新题库文件
leetcode6109. 知道秘密的人数(中等,周赛)
杰理之开发板上电开机,就可以手机打开 NRF 的 APP【篇】