---
# System prepended metadata

title: I2P(I)2020_Yang_lab4

---

# I2P(I)2020_Yang_lab4
[back](https://hackmd.io/@24K/S1rn-G4PD)
### [11146 - Find the maximum/minimum values](https://acm.cs.nthu.edu.tw/contest/2125/)
```c=
#include <stdio.h>
#include <stdlib.h>
int n,m,ma=-1e9,mi=1e9,a,max,may,mix,miy;
int main(void){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++){
            scanf("%d",&a);
            if(a>ma) ma = a,max = i,may = j;
            if(a<mi) mi = a,mix = i,miy = j;
        }
    printf("%d %d",abs(max-mix)+abs(may-miy),ma-mi);
}
```
```c=
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int R, C, arr[20][20]={}, max = 0, posmax[2]={}, min = 0x7fffffff, posmin[2]={};
	scanf("%d%d", &R, &C);
	for(int row = 0; row < R; row++) for(int col = 0; col < C; col++)
	{
		scanf("%d", &arr[row][col]);
		if(arr[row][col] > max)
		{
			max = arr[row][col];
			posmax[0] = row;
			posmax[1] = col;
		}
		if(arr[row][col] < min)
		{
			min = arr[row][col];
			posmin[0] = row;
			posmin[1] = col;
		}
	}
	printf("%d %d", abs(posmax[0]-posmin[0]) + abs(posmax[1]-posmin[1]), max-min);
}
```

### [12901 - Prepare Exam](https://acm.cs.nthu.edu.tw/contest/2125/)

```c=
#include <stdio.h>
#define MX 100005
int main(void){
    int n,x[MX],y[MX],c[105][105]={1},ans = 1,mo = 10007;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&x[i]);
    for(int i=0;i<n;i++) scanf("%d",&y[i]);
    for(int i=1;i<101;i++){
        c[i][0] = 1;
        for(int j=1;j<101;j++)
            c[i][j] = (c[i-1][j]+c[i-1][j-1])%mo;
    }
    for(int i=0;i<n;i++) ans = ans*c[x[i]][y[i]]%mo;
    printf("%d\n",ans);
}
```

```c=
#include<stdio.h>
#define MOD 10007
int combi[500][500]={};

int gen(int n, int k)
{
	int ans;
	if(combi[n][k]) return combi[n][k];
	if(k == 0 || n == k) ans = 1;
	else ans = gen(n-1, k) + gen(n-1, k-1);
	ans %= MOD;
	combi[n][k] = ans;
	return ans;
}
int main()
{
	int N, x[100005]={}, y[100005]={};
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d",&x[i]);
	for(int i = 0; i < N; i++) scanf("%d",&y[i]);
	int ans = 1; 
	for(int i = 0; i < N; i++)
	{
		ans = (ans * gen(x[i], y[i])) % MOD;
	}
	printf("%d\n", ans);
	return 0;
}
```

