40-44行是这个代码的核心做法 但是用这个做法就会wa
查看原帖
40-44行是这个代码的核心做法 但是用这个做法就会wa
597979
DZren楼主2022/12/9 06:45
#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;
}
2022/12/9 06:45
加载中...