洛谷 | 询问学号

其实题目很简单就是用两个数组就可以实现(其实暗含数据的限制,比如10^9,但由于int型最大是2147483647,所以10^9恰好小于此数值,即可用数组来解决),有误的地方还望大佬来斧正。

我的源码:


#include<stdio.h>
#include<stdlib.h>
int main()
{   int n,m;
	int i,j;
	scanf("%d %d",&n,&m); //询问学号
	int a[n],b[m];
	for(i=0;i<=n-1;i++)
	scanf("%d",&a[i]);
    for(j=0;j<=m-1;j++)
    scanf("%d",&b[j]);
    for(j=0;j<=m-1;j++)
   {printf("%d",a[b[j]-1]);
    printf("
");}
}

https://pintia.cn/problem-sets/15/problems/type/6
https://leetcode-cn.com/problemset/all/
https://www.lintcode.com/ladder/2/
https://oi-wiki.org/math/quick-pow/

原文地址:https://www.cnblogs.com/zuoanfengxi/p/12973908.html