Skip to content

Commit

Permalink
Merge branch 'AkashSingh3031:master' into rahul
Browse files Browse the repository at this point in the history
  • Loading branch information
RahulSurana123 authored Jul 25, 2021
2 parents 40178f7 + abc806d commit 4650e56
Show file tree
Hide file tree
Showing 5 changed files with 320 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include<bits/stdc++.h>
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<n;i++)
{
long long int data;
cin>>a[i];
}
for( int i=0;i<n;i++)
{
cout<<a[((n-k+i)%n)]<<" ";
}
cout<<"\n";}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include<bits/stdc++.h>
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);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#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<pair<int, int> > order;
set<int> S;
set<int>::iterator it;
long long ANS;
vector<pair<long long, long long> > 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;
}
92 changes: 77 additions & 15 deletions 6]. Important Books and Resources/Important_Books_Link.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -46,34 +56,86 @@
└── ...
```

1. `Programming Language`
<!-- 1. `Programming Language`
2. [`Data Structures`](#data-structures)
3. [`Algorithms`](#algorithms)
4. [`Competitive Programming`](#competitive-programming)
5. [`Coding Interviews`](#coding-interviews)
6. `Technical Subjects`
7. `Aptitude & Reasoning`
8. [`Low Level Design`](#low-level-design)
8. [`Low Level Design`](#low-level-design) -->

---

## `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`
<table>
<tr>
<td align="center"><a href="#"><img src="https://images-eu.ssl-images-amazon.com/images/I/41a4CcXfN4L._SY264_BO1,204,203,200_QL40_FMwebp_.jpg" width="150px;" alt=""/><br /><sub><b>Let Us C</b></sub></a><br /></td>

<td align="center"><a href="#"><img src="https://images-eu.ssl-images-amazon.com/images/I/51BFuRUjSWL._SY264_BO1,204,203,200_QL40_FMwebp_.jpg" width="150px;" alt=""/><br /><sub><b>C in Depth</b></sub></a><br /></td>
</table>

## `Competitive Programming`
- [Guide to Competitive Programming by `Antti Laaksonen`]()
- [Competitive Programmer’s Handbook by `Antti Laaksonen`]()
- `C++ Language`
<table>
<tr>
<td align="center"><a href="#"><img src="https://images-eu.ssl-images-amazon.com/images/I/51YkwADIq5L._SY264_BO1,204,203,200_QL40_FMwebp_.jpg" width="150px;" alt=""/><br /><sub><b>Let Us C++</b></sub></a><br /></td>

<td align="center"><a href="#"><img src="https://images-na.ssl-images-amazon.com/images/I/51Uqe5PHbML._SX381_BO1,204,203,200_.jpg" width="150px;" alt=""/><br /><sub><b>The Complete Reference</b></sub></a><br /></td>
</table>

- `Python Language`
<table>
<tr>
<td align="center"><a href="#"><img src="https://images-na.ssl-images-amazon.com/images/I/51Ss-7j3v5L._SX362_BO1,204,203,200_.jpg" width="150px;" alt=""/><br /><sub><b>Core Python</b></sub></a><br /></td>
</table>

## `Coding Interviews`
- [Cracking the Coding Interview by `GAYLE LAAKMANN MCDOWELL `]()
- `Java Language`
<table>
<tr>
<td align="center"><a href="#"><img src="https://images-na.ssl-images-amazon.com/images/I/51z+MsmqesL._SX258_BO1,204,203,200_.jpg" width="150px;" alt=""/><br /><sub><b>Core Java - Black Book</b></sub></a><br /></td>
</table>

## `Low Level Design`
## 2. `Data Structures`
<table>
<tr>
<td align="center"><a href="#"><img src="https://images-na.ssl-images-amazon.com/images/I/417ExARdRYL._SX384_BO1,204,203,200_.jpg" width="150px;" alt=""/><br /><sub><b>Data Structures and Algorithms</b></sub></a><br /></td>

<td align="center"><a href="#"><img src="https://images-na.ssl-images-amazon.com/images/I/41fWWCgWk6L._SX384_BO1,204,203,200_.jpg" width="150px;" alt=""/><br /><sub><b>Data Structures and Algorithms</b></sub></a><br /></td>

<td align="center"><a href="#"><img src="https://qphs.fs.quoracdn.net/main-qimg-709c90619378769352a80f5d5dd645e0" width="150px;" alt=""/><br /><sub><b>Data Structures and Algorithms in Python</b></sub></a><br /></td>
</table>

## 3. `Algorithms`
<table>
<tr>
<td align="center"><a href="#"><img src="https://images-na.ssl-images-amazon.com/images/I/513P8XoCAEL._SX376_BO1,204,203,200_.jpg" width="150px;" alt=""/><br /><sub><b>Introduction to Algorithms</b></sub></a><br /></td>

<td align="center"><a href="#"><img src="https://images-na.ssl-images-amazon.com/images/I/41-RWwEls6L._SX400_BO1,204,203,200_.jpg" width="150px;" alt=""/><br /><sub><b>Algorithms</b></sub></a><br /></td>
</table>

## 4. `Competitive Programming`
<table>
<tr>
<td align="center"><a href="#"><img src="https://images-na.ssl-images-amazon.com/images/I/41iVz+I5jOL._SY344_BO1,204,203,200_.jpg" width="150px;" alt=""/><br /><sub><b>Guide to Competitive Programming</b></sub></a><br /></td>

<td align="center"><a href="#"><img src="https://images-na.ssl-images-amazon.com/images/I/41iVz+I5jOL._SY344_BO1,204,203,200_.jpg" width="150px;" alt=""/><br /><sub><b>Competitive Programmer’s Handbook</b></sub></a><br /></td>
</table>

## 5. `Coding Interviews`
<table>
<tr>
<td align="center"><a href="#"><img src="https://images-na.ssl-images-amazon.com/images/I/41oYsXjLvZL._SY291_BO1,204,203,200_QL40_FMwebp_.jpg" width="150px;" alt=""/><br /><sub><b>Cracking the Coding Interview</b></sub></a><br /></td>
</table>

## 6. `Technical Subjects`
-

## 7. `Aptitude & Reasoning`
-

## 8. `Low Level Design`
- [Object Oriented Design](https://www.oodesign.com/)
-

---
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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** 👨🏻‍💻:

Expand Down Expand Up @@ -649,6 +649,8 @@ Thanks goes to these **Wonderful People** 👨🏻‍💻:
<td align="center"><a href="https://github.com/GouravRusiya30"><img src="https://avatars.githubusercontent.com/u/13219295?v=4" width="100px;" alt=""/><br /><sub><b>GouravRusiya30</b></sub></a><br /><a href="https://github.com/AkashSingh3031/The-Complete-FAANG-Preparation/commits?author=GouravRusiya30" title="Commits">💻</a> <a href="https://github.com/AkashSingh3031/The-Complete-FAANG-Preparation/graphs/contributors" title="Contribution Graph">✍️</a></td>

<td align="center"><a href="https://github.com/Akashkhandelwal191"><img src="https://avatars.githubusercontent.com/u/67469131?v=4" width="100px;" alt=""/><br /><sub><b>Akashkhandelwal191</b></sub></a><br /><a href="https://github.com/AkashSingh3031/The-Complete-FAANG-Preparation/commits?author=Akashkhandelwal191" title="Commits">💻</a> <a href="https://github.com/AkashSingh3031/The-Complete-FAANG-Preparation/graphs/contributors" title="Contribution Graph">✍️</a></td>

<td align="center"><a href="https://github.com/RahulSurana123"><img src="https://avatars.githubusercontent.com/u/35515322?v=4" width="100px;" alt=""/><br /><sub><b>RahulSurana123</b></sub></a><br /><a href="https://github.com/AkashSingh3031/The-Complete-FAANG-Preparation/commits?author=RahulSurana123" title="Commits">💻</a> <a href="https://github.com/AkashSingh3031/The-Complete-FAANG-Preparation/graphs/contributors" title="Contribution Graph">✍️</a></td>
</table>


Expand Down

0 comments on commit 4650e56

Please sign in to comment.