2020牛客国庆集训派对day2(补题)

    科技2022-07-11  92

    2020牛客国庆集训派对day2(补题)

    2020牛客国庆集训派对day2


    C ELI’S CURIOUS MIND

    ῟ 题意很简单,这个题采用了递推的思想,首先,我们要知道,我们只需要求得从1和开始递推的序列数就可以了,当我们从大于3的数开始取,那么由于第二条规则,这个数能取到,那么必能取到1和2中的某一个数,所以一个序列一定是从1和2开始的,其次,增加到第i个试管,那么这些试管混合得到的种类就是i - 2和i - 3的种类和,因为由于第二条规则,我们只需要将每一个原序列再后顺延一位,这样可以发现,当试管数增加为i时,试管混合得到的种类就是i - 2和i - 3的和

    大佬代码

    #include<bits/stdc++.h> #define LL long long #define M(a,b) memset(a,b,sizeof a) #define pb(x) push_back(x) using namespace std; const int maxn=1e3+7; int n; LL a[80]; int main() { int cas=1; a[1]=a[2]=0; a[3]=1,a[4]= 3,a[5]=4 , a[6] = 5; for(int i=7;i<=76;i++)a[i]=a[i-2]+a[i-3]; while(scanf("%d",&n)&&n) printf("Case #%d: %lld\n",cas++,a[n]); }

    F 题意我也不太明白,但是似乎不需要明白 找个规律 1 2 3 4 对应的是 (12)2 ,(22)2,(12 + 32)2,(22 + 42)2 这样我们就可以发现当到第k个的时候,如果k%2 == 0就是2 - k的平方和的平方 反之就是1 - k的平方和,而且这两个和的值都是 n(n + !)(n + 2) / 6因为给的n很大,所以如果用c/c++要模拟大数运算,所以我选择那py的大数写掩盖自己不会的事实

    t = int(input()) i = 1 while i <= t: i = i + 1 n = int(input()) ans = n * (n + 1) * (n + 2) // 6 ans *= ans print(ans)

    G

    这个就更简单了,就是单纯的计算利润,没啥技巧,或者说用点小技巧还会出问题(万恶的浮点数)

    #include <iostream> #include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <string> #include <stack> #include <queue> #include <map> #include <vector> using namespace std; typedef unsigned long long ull; typedef long long ll; const int INF = 1e7 + 7; const int MAXN = 300000 + 5; const int Mod = 1e9 + 7; const int N = 5e2; int main() { //std::ios::sync_with_stdio(false); int day; int Case = 0; while(cin>>day,day){ Case++; int chicken , beef , lamb, nasi; float profit = 0; while(day--){ cin>>chicken>>beef>>lamb>>nasi; //先计算卖了多少🤑 profit += 0.8 * chicken + 1.0 * beef + 1.2 * lamb + 0.6 * nasi; //再计算成本 float cost = (chicken * 7.5 + beef * 24 + lamb * 32) / 85 + (chicken + beef + lamb) * 8 * 1.0 / 85 ; profit -= cost; } printf("Case #%d: RM%.2f\n",Case,profit); } return 0; }

    J

    高精度计算,用python可以,cpp开数组模拟也可以

    (1)

    #include <iostream> #include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <string> #include <stack> #include <queue> #include <map> #include <vector> using namespace std; typedef unsigned long long ull; typedef long long ll; const int INF = 1e7 + 7; const int MAXN = 300000 + 5; const int Mod = 1e9 + 7; const int N = 5e2; int fibo[N][N];//一维是位数,二维是每一位组成的数(相当于字符串表示) int main() { int n; fibo[1][0] = 1, fibo[2][0] = 1; while(cin>>n, n != -1){ int d = 0,c = 0;//最大位数 for(int i = 3; i <= n; i++){ //c = 0; for(int j = 0; j <= d; j++){ fibo[i][j] = fibo[i - 1][j] + fibo[i - 2][j] + c; c = fibo[i][j] / 10; fibo[i][j] %= 10; } if(c != 0) fibo[i][++d] = c % 10; c /= 10; } cout<<"Hour: "<<n<<": "; for(int i = d; i >= 0; i--) cout<<fibo[n][i]; cout<<" cow(s) affected"<<endl; } return 0; }

    (2)

    def init(ls): ls.extend([1,1]) for i in range(2,500): ls.append(ls[len(ls) - 1] + ls[len(ls) - 2]) feb = [] init(feb) while True: x = int(input()) if x == -1: break; print('Hour: {:}: {:} cow(s) affected'.format(x,feb[x - 1])) ##print('Hour: {:}: {:} cow(s) affected'.format(x, feb[x - 1]))
    Processed: 0.009, SQL: 8