File tree Expand file tree Collapse file tree 3 files changed +95
-0
lines changed Expand file tree Collapse file tree 3 files changed +95
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ #define lli long long int
3
+ #define endl " \n "
4
+ using namespace std ;
5
+
6
+ int main ()
7
+ {
8
+ lli n, m;
9
+ cin>>n>>m;
10
+ lli maxi = ((n-m+1 )*(n-m))/2 ;
11
+ lli mineach = n/m;
12
+ lli mini;
13
+ if (n<m)
14
+ cout<<0 <<" " <<0 ;
15
+
16
+ else if (m == 1 )
17
+ cout<<n*(n-1 )/2 <<" " <<n*(n-1 )/2 <<" \n " ;
18
+ else if (n%m == 0 )
19
+ {
20
+ cout<<((mineach*(mineach-1 ))/2 ) * m<<" " <<((n-m+1 )*(n-m))/2 <<endl;
21
+ }
22
+ else
23
+ cout<<(m-n%m)*(mineach)*(mineach - 1 )/2 + (n%m)*(mineach)*(mineach + 1 )/2 <<" " <<maxi<<endl;
24
+ return 0 ;
25
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ #define lli long long int
3
+ #define endl " \n "
4
+ using namespace std ;
5
+
6
+ int main ()
7
+ {
8
+ float n, l;
9
+ cin>>n>>l;
10
+ vector <float > v1 (n);
11
+ for (float i =0 ; i<n; i++)
12
+ cin>>v1[i];
13
+ sort (v1.begin (), v1.end ());
14
+ float maxdist = v1[0 ] - 0 ;
15
+ float div = 2 ;
16
+ for (float i =1 ; i<n; i++)
17
+ if (((v1[i] - v1[i-1 ])/div) > maxdist)
18
+ maxdist = (v1[i] - v1[i-1 ])/div;
19
+ if (maxdist <(l-v1[n-1 ]))
20
+ maxdist = (l-v1[n-1 ]);
21
+ cout<<setprecision (9 )<<fixed<<maxdist;
22
+ return 0 ;
23
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+
4
+ int main ()
5
+ {
6
+ int col;
7
+ string s;
8
+ while (1 )
9
+ {
10
+ cin >> col;
11
+ if (col == 0 )
12
+ break ;
13
+ cin >> s;
14
+ int len = s.length ();
15
+ int row = len / col;
16
+ char a[row][col];
17
+ bool toggle = true ;
18
+ int index = 0 ;
19
+ for (int i = 0 ; i < row; i++)
20
+ {
21
+ if (toggle)
22
+ for (int j = 0 ; j < col; j++)
23
+ {
24
+ a[i][j] = s[index];
25
+ toggle = false ;
26
+ index++;
27
+ }
28
+ else
29
+ {
30
+ for (int j = col - 1 ; j > -1 ; j--)
31
+ {
32
+ a[i][j] = s[index];
33
+ toggle = true ;
34
+ index++;
35
+ }
36
+ }
37
+ }
38
+ for (int i = 0 ; i < col; i++)
39
+ {
40
+ for (int j = 0 ; j < row; j++)
41
+ {
42
+ cout << a[j][i];
43
+ }
44
+ }
45
+ cout<<endl;
46
+ }
47
+ }
You can’t perform that action at this time.
0 commit comments