-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
filename: FIBEASY.cpp | ||
author: abhishalya | ||
created: 2019-09-12 14:59:00 | ||
Copyright 2019 @abhishalya | ||
*/ | ||
#include <bits/stdc++.h> | ||
using namespace std; # Ignore CPPLintBear | ||
|
||
typedef long long ll; | ||
|
||
int main() { | ||
ios_base::sync_with_stdio(false); | ||
cin.tie(NULL); cout.tie(NULL); | ||
int t; cin >> t; | ||
int fib[60]; fib[0] = 0, fib[1] = 1; | ||
for(int i = 2; i < 60; i++) { | ||
fib[i] = (fib[i - 1] + fib[i - 2]) % 10; | ||
} | ||
while(t--) { | ||
ll n; cin >> n; | ||
// ll x = log2(n), y = pow(2, x); | ||
ll x = 1; | ||
while(x * 2 <= n) x *= 2; | ||
cout << fib[(x - 1) % 60] << endl; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
filename: A.cpp | ||
author: abhishalya | ||
created: 2019-08-30 20:03:43 | ||
Copyright 2019 @abhishalya | ||
*/ | ||
#include <bits/stdc++.h> | ||
using namespace std; # Ignore CPPLintBear | ||
|
||
int main() { | ||
ios_base::sync_with_stdio(false); cin.tie(NULL); | ||
int n, cnt = 0; cin >> n; | ||
for (int i = 0; i < n; i++) { | ||
int x; cin >> x; | ||
if (x % 2) cnt++; | ||
} | ||
cout << min (cnt, n - cnt) << endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
filename: B.cpp | ||
author: abhishalya | ||
created: 2019-08-30 20:08:55 | ||
Copyright 2019 @abhishalya | ||
*/ | ||
#include <bits/stdc++.h> | ||
using namespace std; # Ignore CPPLintBear | ||
|
||
int main() { | ||
ios_base::sync_with_stdio(false); cin.tie(NULL); | ||
int t; cin >> t; | ||
while (t--) { | ||
int n; cin >> n; | ||
int a[n], mx[n], cnt = 0; | ||
for (int i = 0; i < n; i++) cin >> a[i]; | ||
mx[n - 1] = a[n - 1]; | ||
for (int i = n - 2; i >= 0; i--) { | ||
mx[i] = min(mx[i + 1], a[i]); | ||
} | ||
for (int i = 0; i < n; i++) { | ||
if(a[i] > mx[i]) cnt++; | ||
} | ||
cout << cnt << endl; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
filename: C.cpp | ||
author: abhishalya | ||
created: 2019-08-30 20:23:42 | ||
Copyright 2019 @abhishalya | ||
*/ | ||
#include <bits/stdc++.h> | ||
using namespace std; # Ignore CPPLintBear | ||
|
||
typedef long long ll; | ||
|
||
int main() { | ||
ios_base::sync_with_stdio(false); cin.tie(NULL); | ||
int t; cin >> t; | ||
vector<vector<int> > spv(10); | ||
for(int i = 0; i <= 9; i++) { | ||
int tp = i; | ||
do { | ||
spv[i].push_back(tp); | ||
tp = (tp + i) % 10; | ||
} while(tp != i); | ||
} | ||
while(t--) { | ||
ll n, m; cin >> n >> m; | ||
ll x = n / m, in = m % 10, ti = in, ex = 0, sm = 0; | ||
for(int i = 0; i < x % spv[in].size(); i++) ex += spv[in][i]; sm = ex; | ||
for(int i = x % spv[in].size(); i < spv[in].size(); i++) | ||
sm += spv[in][i]; | ||
cout << ((x / spv[in].size()) * sm) + ex << endl; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
filename: D.cpp | ||
author: abhishalya | ||
created: 2019-08-31 11:42:27 | ||
Copyright 2019 @abhishalya | ||
*/ | ||
#include <bits/stdc++.h> | ||
using namespace std; # Ignore CPPLintBear | ||
|
||
int main() { | ||
ios_base::sync_with_stdio(false); | ||
cin.tie(NULL); cout.tie(NULL); | ||
int n, k; cin >> n >> k; int a[n]; | ||
for(int i = 0; i < n; i++) { | ||
cin >> a[i]; | ||
} | ||
vector<vector<int> > cnts(200005); | ||
for(int i = 0; i < n; i++) { | ||
int tp = a[i], cnt = 0; | ||
while(tp > 0) { | ||
cnts[tp].push_back(cnt); | ||
cnt++; tp /= 2; | ||
} | ||
} | ||
int ans = INT_MAX; | ||
for(int i = 0; i < 200005; i++) { | ||
if(cnts[i].size() < k) continue; | ||
sort(cnts[i].begin(), cnts[i].end()); | ||
ans = min(ans, accumulate(cnts[i].begin(), | ||
cnts[i].begin() + k, 0)); | ||
} | ||
cout << ans << endl; | ||
return 0; | ||
} |