社区讨论
40-44行是这个代码的核心做法 但是用这个做法就会wa
P5724【深基4.习5】求极差 / 最大跨度值 / 最大值和最小值的差参与者 6已保存回复 8
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 8 条
- 当前快照
- 1 份
- 快照标识符
- @lo7dleuv
- 此快照首次捕获于
- 2023/10/27 00:05 2 年前
- 此快照最后确认于
- 2023/10/27 00:05 2 年前
CPP
#include <iostream> //std::cout
#include <algorithm> //reverse
#include <cmath> //ceil
#include <string> //std::string, std::stoi
typedef long long ll;
using std::cout;
const char endl = '\n';
std::string s, ss;
// str255+'/0'
// std::string maxstr = std::to_string(LLONG_MAX);
std::string maxstr;
std::string str[1010];
int maxsum = -1, flag, cnt, sum, arr[1010];
namespace sscio { //quickRead
inline ll pull() {
ll sign = 1LL,res = 0LL;
char ch = getchar();
for (;!isdigit(ch);ch=getchar()) {
if (ch == '-') {
sign *= -1LL;
}
}
for (;isdigit(ch);ch=getchar()) {
res = (res << 3) + (res << 1) - '0' + ch; // *10
}
return sign * res;
}
}
void test() {
for (int i = 0;i < cnt;i ++) {
cout << str[i] << ' ';
} //输出测试
cout << '\n';
}
void solve() {
int n = sscio::pull();
for (int i = 0;i < n;i ++) {
str[i] = std::to_string(sscio::pull());
}
std::sort(str, str + n);
cout << std::stoi(str[n - 1]) - std::stoi(str[0]);
}
signed main() {
solve();
return 0 ^ 0;
}
回复
共 8 条回复,欢迎继续交流。
正在加载回复...