博主水平不高, 只能打完$4$题, QAQ什么时候才能变强啊嘤嘤嘤

 

 


 

订正完6题了,  还想打今天下午的CF , 只能迟十分钟了, 掉分预定

输出 $max - min + n - 1$即可

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 #define rd read()
 5 using namespace std;
 6 
 7 const int N = 1e3 + 5;
 8 const int inf = ~0U >> 1;
 9 
10 int n, a[N], x, maxn, minn = inf;
11 
12 int read () {
13     int X = 0, p = 1; char c = getchar();
14     for(; c > '9' || c < '0'; c = getchar()) if(c == '-') p = -1;
15     for(; c >= '0' && c <= '9'; c = getchar()) X = X * 10 + c - '0';
16     return X * p;
17 }
18 
19 int main()
20 {
21     n = rd;
22     for(int i = 1; i <= n; ++i) {
23         a[i] = rd;
24         minn = min(minn, a[i]);
25         maxn = max(maxn, a[i]);
26     }
27     printf("%d\n", maxn - minn - n + 1);
28 }
Heist

相关文章:

  • 2021-07-04
  • 2021-08-21
  • 2021-09-07
  • 2021-10-09
  • 2020-01-23
  • 2020-02-10
  • 2020-05-07
猜你喜欢
  • 2019-01-03
  • 2021-11-17
  • 2022-01-11
  • 2020-05-15
  • 2021-03-01
  • 2021-10-18
  • 2019-12-20
  • 2021-06-12
相关资源
相似解决方案