为什么只有30pts?

B2078 含 k 个 3 的数

Algorithm_ZRF @ 2023-10-20 21:36:52

#include <cstdio>
#include <cmath>
using namespace std;
int main() {
    int n, k, q = 0;
    scanf("%d%d", &n, &k);
    if (n >= 1) {
        if (n >= 10) {
            if (n >= 100) {
                if (n >= 1000) {
                    if (n >= 10000) {
                        if (n >= 100000) {
                            int a, b, c, d, e, f;
                            a = n % 100000 % 10000 % 1000 % 100 % 10;
                            b = (n % 100000 % 10000 % 1000 % 100 - a) / 10;
                            c = (n % 100000 % 10000 % 1000 - b - a) / 100;
                            d = (n % 100000 % 10000 - c - b - a) / 1000;
                            e = (n % 100000 - d - c - b - a) / 10000;
                            f = (n - e - d - c - b - a) / 100000;
                            if (a == 3) {
                                q += 1;
                            }
                            if (b == 3) {
                                q += 1;
                            }
                            if (c == 3) {
                                q += 1;
                            }
                            if (d == 3) {
                                q += 1;
                            }
                            if (e == 3) {
                                q += 1;
                            }
                            if (f == 3) {
                                q += 1;
                            }
                            if (n % 19 == 0 && q == k) {
                                printf("YES");
                            } else {
                                printf("NO");
                            }
                            return 0;
                        }
                        int a, b, c, d, e;
                        a = n % 10000 % 1000 % 100 % 10;
                        b = (n % 10000 % 1000 % 100 - a) / 10;
                        c = (n % 10000 % 1000 - b - a) / 100;
                        d = (n % 10000 - c - b - a) / 1000;
                        e = (n - d - c - b - a) / 10000;
                        if (a == 3) {
                            q += 1;
                        }
                        if (b == 3) {
                            q += 1;
                        }
                        if (c == 3) {
                            q += 1;
                        }
                        if (d == 3) {
                            q += 1;
                        }
                        if (e == 3) {
                            q += 1;
                        }
                        if (n % 19 == 0 && q == k) {
                            printf("YES");
                        } else {
                            printf("NO");
                        }
                        return 0;
                    }
                    int a, b, c, d;
                    a = n % 1000 % 100 % 10;
                    b = (n % 1000 % 100 - a) / 10;
                    c = (n % 1000 - b - a) / 100;
                    d = (n - c - b - a) / 1000;
                    if (a == 3) {
                        q += 1;
                    }
                    if (b == 3) {
                        q += 1;
                    }
                    if (c == 3) {
                        q += 1;
                    }
                    if (d == 3) {
                        q += 1;
                    }
                    if (n % 19 == 0 && q == k) {
                        printf("YES");
                    } else {
                        printf("NO");
                    }
                    return 0;
                }
                int a, b, c;
                a = n % 100 % 10;
                b = (n % 100 - a) / 10;
                c = (n - a - b) / 100;
                if (a == 3) {
                    q += 1;
                }
                if (b == 3) {
                    q += 1;
                }
                if (c == 3) {
                    q += 1;
                }
                if (n % 19 == 0 && q == k) {
                    printf("YES");
                } else {
                    printf("NO");
                }
                return 0;
            }
            int a, b;
            a = n % 10;
            b = (n - a) / 10;
            if (a == 3) {
                q += 1;
            }
            if (b == 3) {
                q += 1;
            }
            if (n % 19 == 0 && q == k) {
                printf("YES");
            } else {
                printf("NO");
            }
            return 0;
        }
        printf("NO");
        return 0;
    }
    return 0;
}

无语


by coininin @ 2023-10-20 22:03:22

不开long long见祖宗!!!

char数组多是一件美事

#include<bits/stdc++.h>
using namespace std;
int main(){
    char a[20];
    short i=0,sum=0,k;
    cin>>a>>k;
    while(i<strlen(a)){
        if(a[i]=='3'){
            sum++;
        }
        i++;
    }
    if(sum==k){
        cout<<"YES";
        return 0;
    }
    cout<<"NO";
    return 0;
}

by coininin @ 2023-10-20 22:04:48

@AlgorithmArtist 然而代码开了long long也只有40pts(


by coininin @ 2023-10-20 22:08:18

@AlgorithmArtist

hack:

in:333333333333333 15

out:YES

然而你的在开了long long以后输出的是NO


by Xiaonao_Dali @ 2023-10-30 22:26:47

无语,这么长,你是想把所有可能背下来吗?


|