3个WA,其他全RE。请大佬们指点

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

D_M_ @ 2021-10-05 11:09:44

#include <bits/stdc++.h>
using namespace std;
int weishu[10]={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000};
int n,q,a[1010],b[1010],d;
int main(){
    cin >> n >> q;
    for(int i=1;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    for(int i=1;i<q;i++){
        cin >> b[i];
        if(a[i]%weishu[i] == b[i]){
            cout << a[i]%weishu[i];
        }else{
            cout << -1;
        }
    }
    return 0;
}

by QZY2008 @ 2021-10-05 11:12:59

@B站滴魔墨 主页双帖危


by D_M_ @ 2021-10-05 11:14:59

@QZY2008 另外一个已删除


by lion0514 @ 2021-10-05 11:15:39

for(int i=1;i < n;i++)

?


by lion0514 @ 2021-10-05 11:16:16

for(int i=1;i < q;i++)

???

@B站滴魔墨


by D_M_ @ 2021-10-05 11:16:18

@I_am_gone__ 啊?


by lion0514 @ 2021-10-05 11:16:52

@B站滴魔墨 为什么是<


by lion0514 @ 2021-10-05 11:17:08

??????????????


by Eason_AC @ 2021-10-05 11:17:24

@B站滴魔墨 两个 for 循环里面的 < 都是 <= 吧……


by D_M_ @ 2021-10-05 11:17:38

@I_am_gone__ 那怎么写,请大佬指点


by Eason_AC @ 2021-10-05 11:17:38

或者把 1 改成 0


| 下一页