This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <vector>
#include <set>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template<typename Key, typename Compare = std::less<>>
using ordered_set = __gnu_pbds::tree<Key, __gnu_pbds::null_type, Compare, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, tl = 0;
pair<int, int> arr[1001];
multiset<int> sum;
sum.insert(0);
cin >> n;
for (int i = 1; i <= n; i++){
int l, r;
cin >> l >> r;
arr[i] = make_pair(l, r);
}
for (int i = 1; i <= n; i++){
vector<int> rec(sum.begin(), sum.end());
for (int k = 0; k < rec.size(); k++){
sum.erase(sum.find(rec[k]));
for (int j = arr[i].first; j <= arr[i].second; j++){
sum.insert((rec[k] + j) % 5);
}
}
}
for (auto it : sum){
tl += int((pow(it, 4)) + 2 * it * it) % 5 + 1;
}
cout << tl << endl;
}
Compilation message (stderr)
modsum.cpp: In function 'int main()':
modsum.cpp:38:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for (int k = 0; k < rec.size(); k++){
| ~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |