提交时间:2022-04-22 20:05:06
运行 ID: 37830
#include <iostream> #include <algorithm> int read() { int ans = 0; bool neg = false; char c = getchar(); while (c!='-' && !isdigit(c)) c = getchar(); if (c == '-') neg = true, c = getchar(); while (isdigit(c)) ans = 10*ans + c-'0', c = getchar(); return neg ? -ans : ans; } int main(){ int n, r[110], a[110], ans = 0; n = read(), r[1] = read(); for(int i = 1; i <= n; ++i){ a[i] = r[i]%100 + 1; r[i+1] = (r[i]*6807+2831) % 201701; } std::sort(a+1, a+n+1); for (int i = 1; i <= n; i++) { ans += a[i] * (n-i+1); } printf("%d", ans); return 0; }