当前位置:网站首页>2022河南萌新联赛第(二)场:河南理工大学 补题题解
2022河南萌新联赛第(二)场:河南理工大学 补题题解
2022-07-23 08:45:00 【QingQingDE23】
就过了一道题,三道签到的两题都是思路对了但没写出来,只能说自己还是太菜,需要努力!
F 手办
我是个蠢子,考虑出了题意,但怎么就没去算枚举不会超时呢,对不起我以后一定认真对待时间复杂度
这题就是从1开始枚举数的三次方,看那个是n的约束,因为是指数级增长,所以不会超时,亏我还傻傻的在哪算所有1e9以内的符合条件的有理数跑了半天也没写出来,真是个蠢子
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int T;
int n, m;
int main()
{
cin>>T;
while(T -- ){
cin>>n;
int res = 0;
for(int i = 1; i * i * i <= n; i ++ ){
if(n % (i * i * i) == 0) res ++ ;
}
cout<<res<<endl;
}
return 0;
}
J 签到
又是一道证明我是蠢子的题目,思路和正解一样,但是自己考虑的太复杂了,以后要注意简化自己的代码,大道至简,大巧不工,大音希声,大象无形
用n^2的复杂度把所有a+b数放入map中,之后 n ^2枚举d-c,寻找map中是否存在这个数即可,不要自己胡思乱想加上一堆限制条件,最后卡超时了
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
int a[N];
int n;
map<int, int>mp;
int main()
{
cin>>n;
for(int i = 1; i <= n; i ++ ) cin>>a[i];
sort(a + 1, a + 1 + n);
for(int i = 1; i <= n; i ++ ){
for(int j = 1; j <= n; j ++ ){
mp[a[i] + a[j]] = 1;
}
}
for(int i = 1; i <= n; i ++ ){
for(int j = 1; j <= n; j ++ ){
if(mp[a[j] - a[i]] == 1){
cout<<"Yes"<<endl;
return 0;
}
}
}
cout<<"No"<<endl;
return 0;
}
L HPU
简单签到
#include<bits/stdc++.h>
using namespace std;
string str;
int ans;
int main()
{
cin>>str;
for(int i = 0; i < str.length(); i ++ ){
if(str[i] == 'H' && str[i + 1] == 'P' && str[i + 2] == 'U'){
ans ++ ;
}
}
cout<<ans<<endl;
return 0;
}
边栏推荐
- 关于flex布局justify-content:space-around最后一个不对齐的解决方法和为什么这样子解决是讨论
- Canvas from getting started to persuading friends to give up (graphic version)
- Stream stream is used for classification display.
- Chicken and egg, products and Strategies
- Ffmpeg 2 - use of ffplay, ffprobe, ffmpeg commands
- Summary of different circulation modes and precautions in JS
- Summary of JS data type judgment methods
- Chapter 3 complex query
- Shell practice: one click start process, close process and view process status
- STM32输出正弦波+cubeMX配置+HAL库
猜你喜欢
随机推荐
第2章 基礎查詢與排序
Ffmpeg 2 - use of ffplay, ffprobe, ffmpeg commands
c语言实现strcmp、strstr、strcat、strcpy
买卖股票的最佳时机
ValidationError: Invalid options object. Dev Server has been initialized using an options object th
【FLink】FLink Hash collision on user-specified ID “opt“. Most likely cause is a non-unique ID
Consensys Quorum Benchmark Test
FPGA工程师如何进行复杂系统设计?
Quanzhi f1c100s/f1c200s learning notes (13) -- lvgl transplantation
How can manual testing turn to automated testing? Byte 5 years of automation experience talk about
-bash: ifconfig: command not found
Stream stream is used for classification display.
websocket通用化封装设计与实现
基金开户网上办理是否安全?谁给解答一下
解决使用bert encoder出现的一系列问题
Rtx3080ti and rtx3080 gap 3080 and 3080ti parameter comparison
Process blocks and methods
338. 比特位计数
10年软件测试工程师经验,很茫然....
10 years of software testing engineer experience, very confused









