Skip to content

Commit f0d0e28

Browse files
committed
cf728
1 parent 1ef4ab4 commit f0d0e28

File tree

5 files changed

+219
-3
lines changed

5 files changed

+219
-3
lines changed

CF1.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ int fact(int n)
5959
return res % MOD;
6060
}
6161
//////////////////////////////////////////////////////////////////////////////
62-
62+
bool comp(pair<string, int> a, pair<string, int> b)
63+
{
64+
if (a.second != b.second)
65+
return a.second > b.second;
66+
return a.first < b.first;
67+
}
6368
void solve()
6469
{
6570
}
@@ -72,8 +77,8 @@ signed main()
7277
freopen("input.txt", "r", stdin);
7378
freopen("output.txt", "w", stdout);
7479
#endif
75-
int tc;
76-
cin >> tc;
80+
int tc = 1;
81+
//cin >> tc;
7782
while (tc--)
7883
{
7984
solve();

Contests Solutions/CF728/CF1.cpp

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
#############################################
3+
Author: Siddharth Mishra
4+
GitHub: https://github.com/Hard-Coder05
5+
#############################################
6+
*/
7+
#include <bits/stdc++.h>
8+
using namespace std;
9+
#define endl "\n"
10+
#define MOD 1000000007
11+
#define INF INT_MAX
12+
#define ll long long
13+
#define int long long
14+
#define vi vector<int>
15+
#define pii pair<int, int>
16+
#define ld long double
17+
#define PB push_back
18+
#define MP make_pair
19+
#define FF first
20+
#define SS second
21+
#define max(a, b) ( \
22+
{ \
23+
__typeof__(a) _a = (a); \
24+
__typeof__(b) _b = (b); \
25+
_a > _b ? _a : _b; \
26+
})
27+
#define min(a, b) ( \
28+
{ \
29+
__typeof__(a) _a = (a); \
30+
__typeof__(b) _b = (b); \
31+
_a < _b ? _a : _b; \
32+
})
33+
//////////////////////////////////////////////////////////////////////////////
34+
int power(int a, int b)
35+
{
36+
int res = 1ll;
37+
while (b > 0)
38+
{
39+
if (b % 2ll)
40+
res = (res * a) % MOD;
41+
a = (a * a) % MOD;
42+
b /= 2ll;
43+
}
44+
return res;
45+
}
46+
int GCD(int a, int b)
47+
{
48+
if (b == 0)
49+
return a;
50+
return GCD(b, a % b);
51+
}
52+
int fact(int n)
53+
{
54+
int res = 1;
55+
for (int i = 2; i <= n; i++)
56+
{
57+
res = (res * i) % MOD;
58+
}
59+
return res % MOD;
60+
}
61+
//////////////////////////////////////////////////////////////////////////////
62+
63+
void solve()
64+
{
65+
int n;
66+
cin >> n;
67+
68+
if (n % 2 == 0)
69+
{
70+
int i = 2;
71+
while (i <= n)
72+
{
73+
cout << i << " " << i - 1 << " ";
74+
i += 2;
75+
}
76+
}
77+
else
78+
{
79+
int i = 2;
80+
while (i <= n - 3)
81+
{
82+
cout << i << " " << i - 1 << " ";
83+
i += 2;
84+
}
85+
cout << n << " " << n - 2 << " " << n - 1;
86+
}
87+
cout << endl;
88+
}
89+
90+
signed main()
91+
{
92+
ios_base::sync_with_stdio(false);
93+
cin.tie(NULL);
94+
cout.tie(NULL);
95+
#ifndef ONLINE_JUDGE
96+
freopen("input.txt", "r", stdin);
97+
freopen("output.txt", "w", stdout);
98+
#endif
99+
int tc;
100+
cin >> tc;
101+
while (tc--)
102+
{
103+
solve();
104+
}
105+
}

Contests Solutions/CF728/CF2.cpp

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
#############################################
3+
Author: Siddharth Mishra
4+
GitHub: https://github.com/Hard-Coder05
5+
#############################################
6+
*/
7+
#include <bits/stdc++.h>
8+
using namespace std;
9+
#define endl "\n"
10+
#define MOD 1000000007
11+
#define INF INT_MAX
12+
#define ll long long
13+
#define int long long
14+
#define vi vector<int>
15+
#define pii pair<int, int>
16+
#define ld long double
17+
#define PB push_back
18+
#define MP make_pair
19+
#define FF first
20+
#define SS second
21+
#define max(a, b) ( \
22+
{ \
23+
__typeof__(a) _a = (a); \
24+
__typeof__(b) _b = (b); \
25+
_a > _b ? _a : _b; \
26+
})
27+
#define min(a, b) ( \
28+
{ \
29+
__typeof__(a) _a = (a); \
30+
__typeof__(b) _b = (b); \
31+
_a < _b ? _a : _b; \
32+
})
33+
//////////////////////////////////////////////////////////////////////////////
34+
int power(int a, int b)
35+
{
36+
int res = 1ll;
37+
while (b > 0)
38+
{
39+
if (b % 2ll)
40+
res = (res * a) % MOD;
41+
a = (a * a) % MOD;
42+
b /= 2ll;
43+
}
44+
return res;
45+
}
46+
int GCD(int a, int b)
47+
{
48+
if (b == 0)
49+
return a;
50+
return GCD(b, a % b);
51+
}
52+
int fact(int n)
53+
{
54+
int res = 1;
55+
for (int i = 2; i <= n; i++)
56+
{
57+
res = (res * i) % MOD;
58+
}
59+
return res % MOD;
60+
}
61+
//////////////////////////////////////////////////////////////////////////////
62+
63+
void solve()
64+
{
65+
int n, count = 0;
66+
cin >> n;
67+
vector<int> index((2 * n) + 1, INT_MAX);
68+
int j = 0;
69+
while (j < n)
70+
{
71+
int i;
72+
cin >> i;
73+
index[i] = j + 1;
74+
j++;
75+
}
76+
for (int i = 3; i < 2 * n; i++)
77+
{
78+
for (int j = 1; j <= sqrt(i); j++)
79+
{
80+
if (i % j == 0 && i != j * j)
81+
{
82+
if (index[j] + index[i / j] == i)
83+
count++;
84+
}
85+
}
86+
}
87+
cout << count << endl;
88+
}
89+
signed main()
90+
{
91+
ios_base::sync_with_stdio(false);
92+
cin.tie(NULL);
93+
cout.tie(NULL);
94+
#ifndef ONLINE_JUDGE
95+
freopen("input.txt", "r", stdin);
96+
freopen("output.txt", "w", stdout);
97+
#endif
98+
int tc;
99+
cin >> tc;
100+
while (tc--)
101+
{
102+
solve();
103+
}
104+
}

input.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

output.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)