萌新刚学OI,太弱了只能得到40分,求助QAQ

P3955 [NOIP2017 普及组] 图书管理员

applese @ 2019-04-06 21:41:22

40分求助,谢谢大佬指教,代码如下:

#include<iostream>
#include<algorithm>
using namespace std;
int a[10001],b,c,k,ans;
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=m;i++)
    {
        cin>>b>>c;
        for(int j=1;j<=n;j++)
        {
            int small=99999999;
            int find_book_id=a[j];
            int book_id=c;
            while(book_id>0)
            {
                if(find_book_id%10==book_id%10)
                ans++;
                find_book_id/=10;
                book_id/=10;
            }
            if(ans==b)
            {   
                cout<<a[j]<<endl;
                k++;
                break;
            }
            ans=0;
        }
        if(k==0) cout<<-1<<endl;
        k=0;
    }
    return 0;
}

by Kubic @ 2019-04-06 21:43:34

突然莫名伤感

当年因为少写了一个头文件而华丽报0了


by applese @ 2019-04-06 21:47:55

@Kubic QAQ


by Kubic @ 2019-04-06 21:56:19

唉............................................................................ (此处省略10000个省略号)


|