Skip to content

Commit edf30fb

Browse files
authored
Merge branch 'opencodeiiita:main' into main
2 parents 7b3f6ca + a731df8 commit edf30fb

100 files changed

Lines changed: 5962 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.DS_Store

0 Bytes
Binary file not shown.

.gitignore

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

Problems/.DS_Store

0 Bytes
Binary file not shown.

Problems/Mathematics/.DS_Store

2 KB
Binary file not shown.
0 Bytes
Binary file not shown.
12 KB
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// link : https://codeforces.com/problemset/submission/1560/355483452
2+
3+
#include <bits/stdc++.h>
4+
using namespace std;
5+
6+
void solve(){
7+
int x, y, pos;
8+
cin >> x >> y >> pos;
9+
10+
int cs = 2 * abs(x - y);
11+
12+
int opp = pos + cs / 2;
13+
14+
if (pos > cs || y > cs || x > cs) {
15+
cout << -1 << endl;
16+
return;
17+
}
18+
19+
if (opp > cs)
20+
opp -= cs;
21+
22+
cout << opp << endl;
23+
}
24+
25+
int main(){
26+
int t;
27+
cin >> t;
28+
while (t--) solve();
29+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// link : https://codeforces.com/problemset/submission/1225/355484586
2+
3+
4+
#include <bits/stdc++.h>
5+
using namespace std;
6+
7+
void solve() {
8+
int n, k;
9+
if (!(cin >> n >> k)) return;
10+
11+
vector<int> a(n);
12+
for (int &x : a) cin >> x;
13+
14+
map<vector<pair<int, int>>, long long> mp;
15+
long long res = 0;
16+
17+
for (int x : a) {
18+
int t = x;
19+
vector<pair<int, int>> current_factors, required_factors;
20+
21+
for (int p = 2; p * p <= t; p++) {
22+
if (t % p == 0) {
23+
int count = 0;
24+
while (t % p == 0) {
25+
t /= p;
26+
count++;
27+
}
28+
count %= k;
29+
if (count > 0) {
30+
current_factors.push_back({p, count});
31+
required_factors.push_back({p, k - count});
32+
}
33+
}
34+
}
35+
36+
if (t > 1) {
37+
int count = 1 % k;
38+
if (count > 0) {
39+
current_factors.push_back({t, count});
40+
required_factors.push_back({t, k - count});
41+
}
42+
}
43+
44+
if (mp.count(required_factors)) {
45+
res += mp[required_factors];
46+
}
47+
48+
mp[current_factors]++;
49+
}
50+
51+
cout << res << endl;
52+
}
53+
54+
int main() {
55+
ios::sync_with_stdio(false);
56+
cin.tie(nullptr);
57+
58+
solve();
59+
60+
return 0;
61+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
/*
4+
Logic:
5+
The main key in solving the problem is that a,b will be enought to know that the size of the area.
6+
Another observation would be that 1 is always facing the element more than the element which faces
7+
at the last element or the size of the circle.
8+
Once, you get the size of the array, we just have to check if the any of the elements are larger than
9+
the size of the array.
10+
On deeper checks like- a=3, b=2,c=1;
11+
we can observe how this isn't true but how does the conditon fulfill the case?
12+
--> the max check covers all small checks, like the circle don being possible
13+
in cases like a=1,b=6, c=100
14+
--> the circle condition is also checked by the max case.
15+
16+
So, after the checking, we need to see the answer, that can be easily given as the
17+
difference is same for all pairs of elements modular nature of the circle( cool words that make sense)
18+
19+
Time complexity-->
20+
21+
The time complexity is O(1)
22+
The space complexity is O(1)
23+
24+
Submission link- https://codeforces.com/contest/1560/submission/355188467
25+
*/
26+
//Soln->
27+
int main() {
28+
ios::sync_with_stdio(false);
29+
cin.tie(nullptr);
30+
31+
int t;
32+
cin >> t;
33+
34+
while (t--) {
35+
int a,b,c;
36+
cin>>a;
37+
cin>>b;
38+
cin>>c;
39+
int x=abs(b-a);
40+
if(max({a,b,c})>(2*x))
41+
cout<<-1<<endl;
42+
else
43+
{
44+
if(c>x)
45+
cout<<c-x<<endl;
46+
else
47+
cout<<c+x<<endl;
48+
}
49+
50+
}
51+
return 0;
52+
}
53+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
DAY 1
3+
Q1 Who's Opposite?
4+
.*/
5+
6+
typedef long long ll;
7+
#include <bits/stdc++.h>
8+
using namespace std;
9+
10+
int main() {
11+
int t;
12+
cin>>t;
13+
while(t--){
14+
ll a, b, c;
15+
cin >> a >> b >> c;
16+
17+
ll diff = abs(a - b);
18+
ll n = 2 * diff;
19+
20+
if (diff==0 || max({a,b,c})> n){
21+
cout << -1 << endl;
22+
} else {
23+
ll d = c + diff;
24+
if (d > n) d -= n;
25+
cout << d << endl;
26+
}
27+
}
28+
return 0;
29+
}
30+
/*
31+
My submission : https://codeforces.com/contest/1560/submission/355307599
32+
*/

0 commit comments

Comments
 (0)