代码如下:
#include<iostream>
#include<stack>
#include<string>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<climits>
#include<cstdio>
using namespace std;
long long n, m, a[2000001], c;
void r(long long& x)
{
x = 0;
char c = getchar();
while ('0' <= c && c <= '9')
{
x = 10 * x + c - 48;
c = getchar();
}
}
void p(long long x)
{
int b[10], l = 0;
while (x)b[++l] = x % 10 + 48, x /= 10;
++l;
while (--l)putchar(b[l]);
putchar('\n');
}
int main()
{
r(n), r(m);
for (long long i = 1; i <= n; ++i)
{
r(a[i]);
}
for (long long i = 1; i <= m; ++i)
{
r(c);
p(a[c]);
}
return 0;
}
本地测样例是正确的,结果提交了就全错,用scanf,printf就能过