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<bits/stdc++.h>
using namespace std;
long long c (long long n) {
return (n * n + n) >> 1;
}
long long solve (long long n) {
if (n == 3) return 1;
return solve(n-1) + c(n-2);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n, m; cin >> n >> m;
if (n < 3) { cout << 0 << endl; return 0; }
if (n != m) cout << 2ll*solve(n) << endl;
if (n == m) cout << 2ll * c(n-2) * n << endl;
return 0;
}
# | 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... |
# | 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... |