样例过了,但Compile Error
查看原帖
样例过了,但Compile Error
1335977
Windy0430楼主2024/10/21 22:53
#include <bits/stdc++.h>
#include <cstdio>
#define ll long long
using namespace std;
ll n , q , books[1001] , read , num = 0;
int lenth;
void abc(ll &a , ll &b){
	ll c = 0;
	c = b;
	b = a;
	a = c;
}
int main(){
	//freopen(".in" , "r" , stdin);
	//freopen(".out" , "w" , stdout);
	scanf("%ld %ld" , &n , &q);
	for(int i = 1 ; i <= n ; i++){
		scanf("%ld" , &books[i]);
	}
	for(int i = 1 ; i <= n ; i++){
		for(int j = 1 ; j < n ; j++){
			if(books[j] > books[j + 1]){
				abc(books[j] , books[j + 1]);	
			}
		}
	}
	for(int i = 1 ; i <= q ; i++){
		scanf("%d %ld" , &lenth , &read);
		for(int j = 1 ; j <= n ; j++){
			int a = pow(10 , lenth);
			if(books[j] % a == read){
				printf("%ld\n" , books[j]);
				books[j] = -1;
				num++;
				break;
			}
		}
		if(num == 0){
			printf("-1\n");
		}
		num = 0;
	}
	return 0;
}
2024/10/21 22:53
加载中...