当前位置:   article > 正文

题解:::Contest1001 - 河南工程学院2022级新生周赛(一)_haueacm

haueacm

目录

1,1316: Hello , HAUE

2,P1317 - 我必须立刻签到,因为它有手就行http://www.haueacm.top/problem.php?id=1317

3, P1318 - OrzOrzOrz - HAUEOJ (haueacm.top)http://www.haueacm.top/problem.php?id=1318

5,

7,P1322 - 机器人OR寄器人 - HAUEOJ (haueacm.top)http://www.haueacm.top/problem.php?id=1322

8,P1321 - 帕秋莉GO!!! - HAUEOJ (haueacm.top)http://www.haueacm.top/problem.php?id=1321


 

1,1316: Hello , HAUE

P1316 - Hello , HAUE - HAUEOJ (haueacm.top)http://www.haueacm.top/problem.php?id=1316

考察输入输出,和if....else

  1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4. int N;
  5. cin>>N;
  6. if(N==1)
  7. cout<<"One Sail Wind Go"<<endl;
  8. if(N==6)
  9. cout<<"Six Six Big Go"<<endl;
  10. if(N==10)
  11. cout<<"Ten OK Ten OK"<<endl;
  12. if(N==2022)
  13. cout<<"Hello , HAUE"<<endl;
  14. return 0;
  15. }

2,P1317 - 我必须立刻签到,因为它有手就行http://www.haueacm.top/problem.php?id=1317

 本题主要考察递归,这题是比较简单的

  1. #include <iostream>
  2. using namespace std;
  3. int fun(long long x);
  4. int main(){
  5. long long x;
  6. cin>>x;
  7. cout<<fun(x);
  8. return 0;
  9. }
  10. int fun(long long x){
  11. if(x>=0&&x<=10)
  12. return x*x;
  13. if(x>10&&x<=50)
  14. return x*fun(x-5);
  15. if(x>50&&x<=100)
  16. return x+fun(x-10);
  17. }

注意代码 

 if(x>=0&&x<=10)//表达一个数的取值范围,要用和字符即&&

3, P1318 - OrzOrzOrz - HAUEOJ (haueacm.top)http://www.haueacm.top/problem.php?id=1318

这道题需要注意一点的是,

若该编号的大佬是上述列出的大佬且出现过,则输出一个空格后输出"OrzOrzOrz"(不加引号)。 

当时没有注意,以为只是简单的查找,导致第一次没过 

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. int n,m;
  5. char a[10005];
  6. char c;
  7. cin>>n>>m;
  8. for(int i=0;i<n;i++)
  9. cin>>a[i];
  10. for(int i=0;i<m;i++){
  11. int sum=0;
  12. cin>>c;
  13. for(int i=0;i<n;i++){
  14. if(c==a[i])
  15. sum++;
  16. }
  17. if(sum==0)
  18. cout<<sum<<endl;
  19. else {
  20. if(c=='C'||c=='G'||c=='H'||c=='J'||c=='L'||c=='W'||c=='X'||c=='Y'||c=='Z')
  21. cout<<sum<<" "<<"OrzOrzOrz"<<endl;
  22. else
  23. cout<<sum<<endl;}
  24. }
  25. return 0;
  26. }

注意代码 

  1. if(c=='C'||c=='G'||c=='H'||c=='J'||c=='L'||c=='W'||c=='X'||c=='Y'||c=='Z')
  2. cout<<sum<<" "<<"OrzOrzOrz"<<endl;

4,

 

5,

P1320 - 不要停下来啊!!! - HAUEOJ (haueacm.top)http://www.haueacm.top/problem.php?id=1320方法一

  1. #include <iostream>
  2. using namespace std;
  3. char a[100][100];
  4. int main(){
  5. int n,m,k;
  6. int x,y;
  7. cin>>n>>m>>k;
  8. for(int i=0;i<n;i++){
  9. for(int j=0;j<m;j++)
  10. a[i][j]='.';
  11. }
  12. for(int i=0;i<k;i++){
  13. cin>>x>>y;
  14. a[x][y]='#';
  15. }
  16. for(int i=0;i<n;i++){
  17. for(int j=0;j<m;j++){
  18. cout<<a[i][j]<<" ";
  19. }
  20. cout<<endl;
  21. }
  22. return 0;
  23. }

方法二 可以直接打表

6,

 

7,P1322 - 机器人OR寄器人 - HAUEOJ (haueacm.top)http://www.haueacm.top/problem.php?id=1322

这道题把指令用二维数组存储就可以,注意二维数组定义位置,若放在main()函数中就会造成无法输入,就像这样

2a1e86145e584ab09b22222bcc456f93.png

 原因是在main()中,计算机没有足够权限去开辟大的储存空间

  1. #include <iostream>
  2. const int N=1000;
  3. using namespace std;
  4. int h[N][N];//指令存入二维数组
  5. int main(){
  6. int n,m,a,b,f;
  7. cin>>n>>m>>a>>b;
  8. for(int i=0;i<n;i++)
  9. for(int j=0;j<2;j++)
  10. cin>>h[i][j];
  11. for(int i=0;i<m;i++){
  12. cin>>f;
  13. a+=h[f-1][0];
  14. b+=h[f-1][1];
  15. }
  16. cout<<a<<" "<<b;
  17. return 0;
  18. }

 

8,P1321 - 帕秋莉GO!!! - HAUEOJ (haueacm.top)http://www.haueacm.top/problem.php?id=1321

有手就行

  1. #include <stdio.h>
  2. int main()
  3. {
  4. for(int i = 1; i <= 1919; i ++)
  5. printf("114514\n");
  6. return 0;
  7. }

 

 

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/884173
推荐阅读
相关标签
  

闽ICP备14008679号