写在前面

  • 手速还是很关键的啊,有点久没打了回来康复训练,发现手速慢了
  • B 失了智败白给一发,E实在是没想到,D出的慢了点
  • 涨分 1938 -> 1948

A - C+=

简单题,每次加最大的就好了,注意题面是有一个大于 $k$ 就行

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
int Gcd(int a,int b){if (b == 0) return a; return Gcd(b , a%b);}
int Lcm(int a, int b){ return a/Gcd(a,b)*b;}
inline long long read(){
   long long f = 1, x = 0;char ch = getchar();
    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}
const int maxn = 1e6 + 10;
int main(){
    int T = read();
    while(T--){
        LL a = read(),b = read(),n = read();
        LL ans = max(a,b),cnt = 0;
        if (a < b) swap(a,b);
        while(a <= n){
            b += a;
            cnt++;
            if (a < b) swap(a,b);
        }
        cout << cnt << endl;
    }
    return 0;
}

B - Codeforces Subsequences

还是注意别读假题,最后乘积是大于 $K$ 不是等于 $K$ 我们希望最后的可以打到大于 $K$,并且加和最小,只需要每次挨个顺序加一,这样操作不会太多,因为 $k \le n^{10}$ 对于不需要很大的 $n$ 就可以做到

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
int Gcd(int a,int b){if (b == 0) return a; return Gcd(b , a%b);}
int Lcm(int a, int b){ return a/Gcd(a,b)*b;}
inline long long read(){
   long long f = 1, x = 0;char ch = getchar();
    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}
const int maxn = 1e6 + 10;
int a[maxn];
char s[100] = "xcodeforces";
int main(){
    LL k = read();
    for(int i=1; i<=10; i++){
        a[i] = 1;
    }
    int cur = 1;
    for(int j=1; j<=1000; j++){
        LL ans = 1;
        for(int i=1; i<=10; i++){
            ans *= a[i];
        }
        if (ans >= k) {
            for(int i=1; i<=10; i++){
                for(int j=0; j<a[i]; j++){
                    cout << s[i];
                }
            }
            cout << endl;
            return 0;
        }
        a[cur]++;
        cur = (cur + 1) % 11;
        if (cur == 0) cur = 1;
    }   
    return 0;
}

C - Even Picture

就硬找规律,比如 $n=2$,那就是下面的包围方法,$n=3$ 就在右下再加一层,其他同理。~~~~
image.png

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
int Gcd(int a,int b){if (b == 0) return a; return Gcd(b , a%b);}
int Lcm(int a, int b){ return a/Gcd(a,b)*b;}
inline long long read(){
   long long f = 1, x = 0;char ch = getchar();
    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}
const int maxn = 1e6 + 10;
int main(){
    int n = read();
    int xx = 1000,yy = 1000,ans = 3 * n + 4;
    printf("%d\n",ans);
    printf("%d %d\n",xx,yy);
    printf("%d %d\n",xx,yy-1);
    xx++;
    for(int i=1; i<=n; i++){
        printf("%d %d\n",xx,yy);
        printf("%d %d\n",xx,yy-1);
        printf("%d %d\n",xx,yy-2);
        xx++; yy--;
    }   
    printf("%d %d\n",xx,yy);
    printf("%d %d\n",xx,yy-1);
    return 0;
}

D - AND, OR and square sum

打表试下之后就会发现,两个数做一次题面中的操作平方和是不减的,其实证明的话就把每个数拆成二进制加和然后平方就可以证明。

再观察这个操作,如果两个数的某一位分别是 0,1 那么这个操作相当于把1给到大的那个数上,如果是1,1或者0,0则不发生变化。

因此我们统计所有位上的1,然后优先凑尽可能大的数就好了

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
int Gcd(int a,int b){if (b == 0) return a; return Gcd(b , a%b);}
int Lcm(int a, int b){ return a/Gcd(a,b)*b;}
inline long long read(){
   long long f = 1, x = 0;char ch = getchar();
    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}
const int maxn = 1e6 + 10;
int cnt[maxn],a[maxn];
int main(){
    int n = read();
    for(int i=1; i<=n; i++){
        a[i] = read();
        for(int j=0; j<=21; j++){
            if ((1 << j) & a[i]){
                cnt[j]++;
            }
        }
    }   
    LL ans = 0;
    for(int i=1; i<=n; i++){
        LL res = 0;
        for(int j=0; j<=21; j++){
            if (cnt[j]){
                cnt[j]--;
                res += 1 << j;
            }
        }
        ans += res * res;
    }
    cout << ans << endl;
    return 0;
}

E - Ski Accidents

挖坑,人都打晕了


TongChu
1 声望0 粉丝

练习编程两年半的个人练习生