SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <iostream> | |
| 2 | #include <fstream> | |
| 3 | ||
| 4 | using namespace std; | |
| 5 | ||
| 6 | - | int i,j,k,r,l,c,m,N,pomN,br,kol,pkol; |
| 6 | + | |
| 7 | - | cin>>N; |
| 7 | + | |
| 8 | ifstream in; | |
| 9 | ofstream out; | |
| 10 | ||
| 11 | - | cin>>a[i]; |
| 11 | + | in.open("freksuma.16.in");
|
| 12 | out.open("freksuma.16.out");
| |
| 13 | ||
| 14 | long i,j,k,r,N,pomN; | |
| 15 | long c, l, kol,pkol, br, m; | |
| 16 | in>>N; | |
| 17 | int a[N]; | |
| 18 | long s[(N*(N+1))/2]; | |
| 19 | for(i=0;i<N;i++) | |
| 20 | in>>a[i]; | |
| 21 | ||
| 22 | m=0; | |
| 23 | pomN=N; | |
| 24 | for(j=0;j<N;j++){
| |
| 25 | s[m]=a[j]; | |
| 26 | r=0; | |
| 27 | for(k=j+1;k<N;k++){
| |
| 28 | r++; | |
| 29 | s[r+m]=s[r+m-1]+a[k]; | |
| 30 | } | |
| 31 | m+=pomN; | |
| 32 | pomN--; | |
| 33 | } | |
| 34 | ||
| 35 | /* for(l=0;l<((N*(N+1))/2);l++) | |
| 36 | cout<<s[l]<<" "; | |
| 37 | cout<<endl; | |
| 38 | */ | |
| 39 | br=0; | |
| 40 | kol=1; | |
| 41 | for(l=0;l<((N*(N+1))/2);l++){
| |
| 42 | if(s[l]==-1){}
| |
| 43 | else{
| |
| 44 | pkol=1; | |
| 45 | for(c=l+1;c<((N*(N+1))/2);c++){
| |
| 46 | if(s[c]==s[l]){
| |
| 47 | pkol++; | |
| 48 | s[c]=-1; | |
| 49 | } | |
| 50 | } | |
| 51 | - | cout<<br<<" "<<kol<<endl; |
| 51 | + | |
| 52 | br=s[l]; | |
| 53 | kol=pkol; | |
| 54 | } | |
| 55 | else if((pkol==kol)&&(s[l]>br)) | |
| 56 | br=s[l]; | |
| 57 | } | |
| 58 | } | |
| 59 | ||
| 60 | out<<br<<" "<<kol<<endl; | |
| 61 | ||
| 62 | return 0; | |
| 63 | } |