当前位置:网站首页>Openjudge noi 1.13 14: find the 3 digits that meet the conditions
Openjudge noi 1.13 14: find the 3 digits that meet the conditions
2022-06-10 04:34:00 【Junyi_ noip】
【 Topic link 】
OpenJudge NOI 1.13 14: Seek to satisfy the condition 3 digit
【 Topic test site 】
1. enumeration
2. Digital split
【 Their thinking 】
The overall idea is enumeration .
x From small to large , x 2 x^2 x2 For this perfect square number . The result is three digits , therefore x The minimum value of is 10, x 2 x^2 x2 Less than the maximum 1000.
Each cycle , First seek x 2 x^2 x2 Get a complete square number , Then do a numerical split on this number , Split it into bits , ten , Hundred bit . Judge whether two of the three digits are the same .
If the number is conditional , Count .
If the count reaches n, Then output the n A number that satisfies the condition .
【 Solution code 】
solution 1: enumeration
#include <iostream>
using namespace std;
int main()
{
int n, i = 0, x = 10, num, g, s, b;
cin >> n;
for(int x = 10; x*x < 1000; x++)
{
num = x*x;// A perfect square number
g = num%10;// bits
s = num/10%10;// ten
b = num/100;// Hundred bit
if(g == s || g == b || s == b)// If there is 2 Same bit
{
++i;// Numbers num It's No i Eligible numbers
if(i == n)
{
cout << num;
return 0;
}
}
}
return 0;
}
边栏推荐
- The relationship between libc, glibc and glib
- Mindspore 1.5rcGraph Mode训练速度慢,这是为什么?
- Eight part essay ceiling! (PDF HD download)
- Fastapi-17-page beautification-2
- [understanding of opportunity -22]: Guiguzi - the art of closing Tibet. Collect your talents in time to protect yourself in the workplace, business and business activities
- 使用MindSpore多数据集混合采样并加载
- CSDN audio and video technology developers' online survey
- 23 个非常实用的 Shell 脚本
- PySimpleGUI经典实践之:这个汉字怎么读?
- AI candidates challenge the composition of the college entrance examination, generating one essay in one second on average, with the level of more than 75% of the candidates
猜你喜欢

5 minutes to learn how to set up local pypi source

Using kubekey to build kubernetes/kubesphere environment

Log management of MySQL database

Execution strategy of application software efficiency test
![[android l]seandrod security enhancement background summary and impact](/img/cf/591fc78cdf158b31fac86a092adc49.png)
[android l]seandrod security enhancement background summary and impact

MeterSphere | 超好用的开源测试平台

24. 浏览器对象模型 BOM

Pampy | 超强的模式匹配工具

Gevent | 异步就用它!
Webcodecs parsing GIF graph
随机推荐
APISpace 分钟级降水预报API接口 免费好用
Pampy | powerful pattern matching tool
如何用全国天气预报API接口进行快速开发
[understanding of opportunity -22]: Guiguzi - the art of closing Tibet. Collect your talents in time to protect yourself in the workplace, business and business activities
Full path of idea replication method
MindSpore缺失与torch.nn.Maxpool3d和torch.nn.Avgpool3d对标的算子
Application of PhD debate 𞓜 self supervised learning in Recommendation System
EasyRecovery数据恢复软件100%恢复的成功率
torch.randn迁移成mindspore.ops.TruncatedNormal使用问题
【深度学习】《PyTorch入门到项目实战》(十一):卷积层
分布式数据对象:超级终端的'全局变量'
FastApi-14-文件上传-2
这些编程语言老了,差不多死透了,年轻人不能碰
tensorflow 中的 cross_entropy
PMP项目管理计算中字母含义 PV、EV、AC、SV、CV、SPI、CPI
.NET C#基礎(7):接口 - 人如何和猫互動
24. 浏览器对象模型 BOM
When to use @componentscan? What is the difference with @mapperscan?
常见的数据库-字段类型映射关系
超好用的 Chrome 插件!