Download spoj_cpp_clean/ABSP1/ABSP1-3.cpp from slayone/uva_spoj_raw: direct link, hf CLI and curl.
- Browser
- Download file 964 Bytes
-
https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/spoj_cpp_clean/ABSP1/ABSP1-3.cpp
- Command line
-
hf download hf://datasets/slayone/uva_spoj_raw/spoj_cpp_clean/ABSP1/ABSP1-3.cpp
-
curl -L -o ABSP1-3.cpp https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/spoj_cpp_clean/ABSP1/ABSP1-3.cpp
964 Bytes
| using namespace std; | |
| int main(){ | |
| int t, n, fact; | |
| long long nums[10000], sum[10000], total; | |
| sd(t); | |
| while(t--){ | |
| sd(n); | |
| if(n == 0 or n == 1){ | |
| printf("0\n"); | |
| continue; | |
| } | |
| for(int i = 0; i < n; i++){ | |
| scanf("%lld",&nums[i]); | |
| } | |
| sum[n-1] = nums[n-1]; | |
| for(int i = n-2; i >= 0; i--){ | |
| sum[i] = sum[i+1] + nums[i]; | |
| } | |
| total = 0; | |
| for(int i = 0; i < n-1; i++){ | |
| total += abs((n-i-1)*nums[i] - sum[i+1]); | |
| } | |
| printf("%lld\n",total); | |
| } | |
| return 0; | |
| } | |