## A. 最短逃生距离

```# include <stdio.h>
# include <math.h>

int main() {
int n, m;
scanf("%d%d", &n, &m);

while (m--) {
int x, y;
scanf("%d%d", &x, &y);

printf("%d\n", abs(x - y));
}

return 0;
}```

```# include <iostream>
# include <cmath>

int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);

int n, m;
std::cin >> n >> m;

while (m--) {
int x, y;
std::cin >> x >> y;

std::cout << abs(x - y) << "\n";
}

return 0;
}```

```# include <iostream>
# include <cstdio>
# include <cmath>

template <typename T>
T x = 0;
int bz = 1;
char c;

for (c = getchar(); (c<'0' || c>'9') && c != '-';  c = getchar()) ;

if (c == '-') {
bz = -1;
c = getchar();
}

for (; c >= '0' && c <= '9'; c = getchar())
x = x * 10 + c - 48;

val = x * bz;
}

template <typename T>
void put(T x){
static char    ss[20];
int bas;

if(x < 0) {
putchar('-');
x = -x;
}

if(x == (T)(0)) {
putchar('0');
return;
}

bas = 0;
for(;x;x/=10)
ss[bas++] = x % 10 + '0';

for(;bas--;)
putchar(ss[bas]);
}

int main() {
int n, m;

while (m--) {
int x, y;

put(abs(x - y));
puts("");
}

return 0;
}```

```# include <iostream>
# include <cstdio>
# include <cmath>

const int BUFSIZE = 20 << 20; //40M
char Buf[BUFSIZE + 1], *buf = Buf;

template<class T>
int sgn = 1;
for(a=0; *buf<'0'||*buf>'9'; buf++) if(*buf=='-') sgn = -1;
while(*buf>='0'&&*buf<='9') {
a=a*10+(*buf-'0');
buf++;
}

a *= sgn;
}

void put(int x) {
static char s[20];
int bas;

if(x < 0) {
putchar('-');
x = -x;
}

if(x == 0) {
putchar('0');
return;
}

bas = 0;
for(; x; x/=10)
s[bas++] = x%10+'0';

for(; bas--;)
putchar(s[bas]);
}

int main() {

int n, m;
while (m--) {
int x, y;

put(abs(x - y));
printf("\n");
}

return 0;
}```

## B. spj

```# include <cstdio>

int main() {
printf("1\n\kcxz");

return 0;
}```
```# include <cstdio>

int main() {
printf("2\n\小少爷\n宇少");

return 0;
}```
```# include <cstdio>

int main() {
printf("2\n宇少\n小少爷");

return 0;
}```

## C. 突然想到一个算法

```# include <stdio.h>

const int mod = 1e9 + 7;

int pow(int x, int p) {
int ans = 1 % mod;

while (p) {
if (p & 1) {
ans = 1ll * ans * x % mod;
}

x = 1ll * x * x % mod;
p >>= 1;
}

return ans;
}

void solve() {
int n;
scanf("%d", &n);

int ans = n;
for (int i = 2; i <= n; i++) {
ans = pow(ans, i);
}

printf("%d\n", ans);
}

int main() {
int T;
scanf("%d", &T);

while (T--) {
solve();
}

return 0;
}```

```# include <stdio.h>

const int mod = 1e9 + 7;
int phi;

int qpow(int x, int p) {
int ans = 1 % mod;

while (p) {
if (p & 1) {
ans = 1ll * ans * x % mod;
}

x = 1ll * x * x % mod;
p >>= 1;
}

return ans;
}

int fphi(int n) {
int ans = n;
for (int i = 2; i <= n / i; i++) {
if (n % i == 0) {
ans = ans / i * (i - 1);

while (n % i == 0) {
n /= i;
}
}
}

if (n > 1) {
ans = ans / n * (n - 1);
}

return ans;
}

void solve() {
int n;
scanf("%d", &n);

int ans = 1;
for (int i = 2; i <= n; i++) {
ans = 1ll * ans * i % phi;
}

printf("%d\n", qpow(n, ans));
}

int main() {
int T;
scanf("%d", &T);
phi = fphi(mod);

while (T--) {
solve();
}

return 0;
}```

## D. 兀兀的请求

。C语言的库函数里面 写作 。部分编译器无法通过，需要写成

```# include <stdio.h>
# include <math.h>

typedef long long ll;

int main() {
double ans = acos(-1.0);
ans = ans * 100;

for (int i = 3; i <= 14; i++) {
ans = ans * 10;
ll t = ans;
printf("%lld", t % 10);
}

return 0;
}```