diff --git a/3]. Competitive Programming/05]. HackerEarth/1]. Practice/5]. Code Monk Series/1] Arrays & Strings/Monk and Rotation.cpp b/3]. Competitive Programming/05]. HackerEarth/1]. Practice/5]. Code Monk Series/1] Arrays & Strings/Monk and Rotation.cpp new file mode 100644 index 000000000..7f68a581b --- /dev/null +++ b/3]. Competitive Programming/05]. HackerEarth/1]. Practice/5]. Code Monk Series/1] Arrays & Strings/Monk and Rotation.cpp @@ -0,0 +1,25 @@ +#include +using namespace std; + +int main() +{ + int T; + cin>>T; + while(T--) + + { + long long int n,k; + cin>>n>>k; + k=k%n; + long long int a[n]; + for(long long int i=0;i>a[i]; + } + for( int i=0;i +using namespace std; +#define int long long +#define endl "\n" +#define fastio() ios::sync_with_stdio(0);cin.tie(0) +#define mod 1000000009 + +void io() +{ + ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); + #ifndef ONLINE_JUDGE + freopen("/home/kashif/cp/input.txt","r",stdin); + + freopen("/home/kashif/cp/output.txt","w",stdout); + #endif + +} +int i,j,k; +int M[4][4] = {{0,99,-10,2},{1,0,0,0},{0,1,0,0},{0,0,0,10}}; +int p; +void multiply(int a[4][4],int b[4][4]) +{ + + int mul[4][4]={0}; + for(i=0;i<4;i++) + { + for(j=0;j<4;j++) + { + for(k=0;k<4;k++) + { + + p=(a[i][k]*b[k][j]); + mul[i][j]=(mul[i][j]+p); + + } + } + } + + + for(i=0;i<4;i++) + { + for(j=0;j<4;j++) + a[i][j]=mul[i][j]%mod; + } + +} +void power(int a[4][4],int n) +{ + if(n==1 || n==0) + return; + power(a,n/2); + multiply(a,a); + if (n%2 != 0) + multiply(a,M); +} + +int32_t main() +{ + + fastio(); + io(); + int t,n,ans; + cin>>t; + while(t--) + { + + cin>>n; + if(n==0) + printf("%d\n",1); + else if(n==1) + printf("%d\n",10); + else if(n==2) + printf("%d\n",99); + else if(n==3) + printf("%d\n",980); + else + { + int a[4][4]={{0,99,-10,2},{1,0,0,0},{0,1,0,0},{0,0,0,10}}; + power(a,n-3); + p=(a[3][3]*1000); + k=(a[0][0]*20+a[0][1]+100*a[0][3])%mod; + ans=(p-k+mod)%mod; + printf("%lld\n",ans); + } + } +} diff --git a/3]. Competitive Programming/05]. HackerEarth/1]. Practice/5]. Code Monk Series/6]. Check Point - 1/Monk Celebrating Checkpoint.cpp b/3]. Competitive Programming/05]. HackerEarth/1]. Practice/5]. Code Monk Series/6]. Check Point - 1/Monk Celebrating Checkpoint.cpp new file mode 100644 index 000000000..db6c47591 --- /dev/null +++ b/3]. Competitive Programming/05]. HackerEarth/1]. Practice/5]. Code Monk Series/6]. Check Point - 1/Monk Celebrating Checkpoint.cpp @@ -0,0 +1,129 @@ +#define _CRT_SECURE_NO_WARNINGS +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define y0 sdkfaslhagaklsldk + +#define y1 aasdfasdfasdf +#define yn askfhwqriuperikldjk +#define j1 assdgsdgasghsf +#define tm sdfjahlfasfh +#define lr asgasgash +#define norm asdfasdgasdgsd +#define have adsgagshdshfhds + +#define eps 1e-7 +#define M_PI 3.141592653589793 +#define bs 1000000007 +#define bsize 337 + +using namespace std; + +const int INF = 1e9; +const int N = 300031; + +int n, ar[N]; +int k, x; +vector > order; +set S; +set::iterator it; +long long ANS; +vector > T; +long long C[N]; + +int main(){ + //freopen("tree.in","r",stdin); + //freopen("tree.out","w",stdout); + // freopen("F:/input.txt", "r", stdin); + // freopen("F:/output.txt", "w", stdout); + ios_base::sync_with_stdio(0); + //cin.tie(0); + + cin >> n >> x >> k; + for (int i = 1; i <= n; i++) + { + cin >> ar[i]; + order.push_back(make_pair(ar[i], i)); + } + + S.insert(0); + S.insert(n+1); + + sort(order.begin(), order.end()); + + reverse(order.begin(), order.end()); + + for (int i = 0; i < order.size(); i++) + { + int ps = order[i].second; + it = S.lower_bound(ps); + int val1 = (*it); + --it; + int val2 = (*it); +// cout << val1 << " " << val2 << endl; + + long long here = (val1 - ps) * 1ll * (ps - val2 ); + //cout << here << "%" << ar[ps] << endl; + ANS += 1ll * here*ar[ps]; + C[ps] = here; + S.insert(ps); + } + //cout << ANS << endl; + + S.clear(); + sort(order.begin(), order.end()); + S.insert(0); + S.insert(n + 1); + + for (int i = 0; i < order.size(); i++) + { + int ps = order[i].second; + it = S.lower_bound(ps); + int val1 = (*it); + --it; + int val2 = (*it); + // cout << val1 << " " << val2 << endl; + + long long here = (val1 - ps) * 1ll * (ps - val2); + //cout << here << "%" << ar[ps] << endl; + ANS -= 1ll * here*ar[ps]; + //T.push_back(make_pair(here, ps)); + C[ps] -= here; + S.insert(ps); + T.push_back(make_pair(C[ps], ps)); + } + + /*for (int i = 1; i <= n; i++) + { + cout << C[i] << " "; + } + cout << endl; + */ + sort(T.begin(), T.end()); + reverse(T.begin(), T.end()); + + for (int i = 0; i < x; i++) + { + if (T[i].first>0) + ANS += T[i].first; + } + cout << ANS << endl; + + cin.get(); cin.get(); + return 0; +} diff --git a/6]. Important Books and Resources/Important_Books_Link.md b/6]. Important Books and Resources/Important_Books_Link.md index 24c9bfe40..09b54740d 100644 --- a/6]. Important Books and Resources/Important_Books_Link.md +++ b/6]. Important Books and Resources/Important_Books_Link.md @@ -5,9 +5,19 @@ └── π‘°π’Žπ’‘π’π’“π’•π’‚π’π’• π‘©π’π’π’Œπ’” | β”œβ”€β”€ Programming Language | | β”œβ”€β”€ C +| | | β”œβ”€β”€ Let Us C by Yashwant P. Kanetkar +| | | β”œβ”€β”€ C in Depth by S. K. Srivastava +| | | └── ... | | β”œβ”€β”€ C++ +| | | β”œβ”€β”€ Let Us C++ by Yashwant P. Kanetkar +| | | β”œβ”€β”€ C++: The Complete Reference by Herbert Schildt +| | | └── ... | | β”œβ”€β”€ Python +| | | β”œβ”€β”€ Core Python by R. Nageswara Rao +| | | └── ... | | β”œβ”€β”€ Java +| | | β”œβ”€β”€ Core Java - Black Book by R. Nageswara Rao +| | | └── ... | | └── ... | | | β”œβ”€β”€ Data Structures @@ -46,34 +56,86 @@ └── ... ``` -1. `Programming Language` + --- -## `Data Structures` -- [Data Structures and Algorithms by `Narasimha Karumanchi`]() -- [Data Structures and Algorithms in Python by `Michael T. Goodrich`]() +## 1. `Programming Language` -## `Algorithms` -- [Introduction to Algorithms by `Thomas H. Cormen`]() -- [Algorithms by `Robert Sedgewick` and `Kevin Wayne`]() +- `C Language` + + + + + +

Let Us C


C in Depth

-## `Competitive Programming` -- [Guide to Competitive Programming by `Antti Laaksonen`]() -- [Competitive Programmer’s Handbook by `Antti Laaksonen`]() +- `C++ Language` + + + + + +

Let Us C++


The Complete Reference

+- `Python Language` + + + +

Core Python

-## `Coding Interviews` -- [Cracking the Coding Interview by `GAYLE LAAKMANN MCDOWELL `]() +- `Java Language` + + + +

Core Java - Black Book

-## `Low Level Design` +## 2. `Data Structures` + + + + + + + +

Data Structures and Algorithms


Data Structures and Algorithms


Data Structures and Algorithms in Python

+ +## 3. `Algorithms` + + + + + +

Introduction to Algorithms


Algorithms

+ +## 4. `Competitive Programming` + + + + + +

Guide to Competitive Programming


Competitive Programmer’s Handbook

+ +## 5. `Coding Interviews` + + + +

Cracking the Coding Interview

+ +## 6. `Technical Subjects` +- + +## 7. `Aptitude & Reasoning` +- + +## 8. `Low Level Design` - [Object Oriented Design](https://www.oodesign.com/) -- + --- diff --git a/README.md b/README.md index 9b69fd926..433f1d74c 100644 --- a/README.md +++ b/README.md @@ -560,7 +560,7 @@ This repository contains all the DSA (Data-Structures, Algorithms, 450 DSA by Lo | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | | **[Akash Singh](https://www.linkedin.com/in/akash-singh3031/)** | -## `Awesome Contributors βœ¨πŸŽ‰` `37` +## `Awesome Contributors βœ¨πŸŽ‰` `38` Thanks goes to these **Wonderful People** πŸ‘¨πŸ»β€πŸ’»: @@ -649,6 +649,8 @@ Thanks goes to these **Wonderful People** πŸ‘¨πŸ»β€πŸ’»:
GouravRusiya30

πŸ’» ✍️
Akashkhandelwal191

πŸ’» ✍️ + +
RahulSurana123

πŸ’» ✍️