基于2-26日dotcpp月赛及暨蓝桥杯专场

第一个水题链接:https://www.dotcpp.com/oj/contest4104_problem0.html

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int n,m;
 4 int a[110][110];
 5 int main()
 6 {
 7     ios::sync_with_stdio(false);
 8     cin>>n>>m;
 9     for(int i=0;i<n;i++)
10     {
11         for(int j=0;j<m;j++)
12         {
13             cin>>a[i][j];
14         }
15     }
16     for(int i=0;i<m;i++)
17     {
18         for(int j=n-1;j>=0;j--)
19         {
20             cout<<a[j][i]<<' ';
21         }
22         cout<<endl;
23     }
24     return 0;
25 }

另一个难度很高,题目链接:https://www.dotcpp.com/oj/contest4104_problem3.html

相关注释以及ac代码如下:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 double a(long long  n)//dp 
 4 {
 5     long long b[n];
 6     if(n<1)
 7     return -1;
 8     b[1]=1;
 9     b[2]=1;
10     for(int i=3;i<=n;i++)
11     {
12         b[i]=b[i-1]+b[i-2];
13     }
14     return b[n];
15 }
16 int main()
17 {
18     ios::sync_with_stdio(false);
19     long long n;
20     cin>>n;
21     if(n<20)
22     {
23         printf("%.8lf",a(n)/a(n+1));//dp内容解决 
24     }
25     else
26     {
27         printf("0.61803399");//黄金分割率输出 
28     }
29     return 0;
30 }

 

posted @ 2022-02-27 20:05  江上舟摇  阅读(38)  评论(0编辑  收藏  举报