-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
83 changed files
with
2,391 additions
and
6 deletions.
There are no files selected for viewing
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
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
Empty file.
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,41 @@ | ||
# Things I learned in: Day_16 | ||
**Note:** use the github provided TOC for navigaing. | ||
|
||
## Binary to decimal: | ||
**Formula:** | ||
For binary number fedcba , Decimal number = f * 2^5 + e * 2^4 + d * 2^3 + …..+ a * 2^0. | ||
```cpp | ||
int main(){ | ||
int t=1; | ||
cin>>t; | ||
while((t--)>0){ | ||
long long data; | ||
cin>>data; | ||
int len = 0; | ||
|
||
long long dec = 0; | ||
|
||
while(data!=0){ | ||
dec += (data%10)*pow(2,len); | ||
len++; | ||
data /= 10; | ||
} | ||
cout<<dec<<endl; | ||
|
||
} | ||
return 0; | ||
} | ||
``` | ||
|
||
## Farenhiet to celsius: | ||
got to know that there are different kinds of divisions available, integer devision,float devision, double devision etc. | ||
Source: [https://stackoverflow.com/questions/27971967/c-does-not-take-5-9-and-seems-to-typecast-it](https://stackoverflow.com/questions/27971967/c-does-not-take-5-9-and-seems-to-typecast-it) | ||
|
||
**For example:** if you do `cout<<5/9` then its a integer devide so it will give you 0,not 0.55555, so u need to do it in floating way. | ||
``` | ||
5 // int | ||
5l // long | ||
5.0 // double | ||
5.0f // float | ||
5ul // unsigned long | ||
``` |
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,50 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
#define print(x) cout << x | ||
#define deb(x) cout << #x << "=" << x << endl; | ||
// 101 -> 5 | ||
// For binary number fedcba , Decimal number = f * 2^5 + e * 2^4 + d * 2^3 + …..+ a * 2^0. | ||
typedef long long ll; | ||
typedef unsigned long long ull; | ||
typedef long double lld; | ||
|
||
#ifndef ONLINE_JUDGE | ||
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl; | ||
#else | ||
#define debug(x) | ||
#endif | ||
|
||
void _print(ll t) {cerr << t;} | ||
void _print(int t) {cerr << t;} | ||
void _print(string t) {cerr << t;} | ||
void _print(char t) {cerr << t;} | ||
void _print(lld t) {cerr << t;} | ||
void _print(double t) {cerr << t;} | ||
void _print(ull t) {cerr << t;} | ||
|
||
int main(){ | ||
#ifndef ONLINE_JUDGE | ||
freopen("errorf.in", "w", stderr); | ||
#endif | ||
|
||
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); | ||
int t; | ||
cin>>t; | ||
while((t--)>0){ | ||
long long data; | ||
cin>>data; | ||
int len = 0; | ||
debug(len); | ||
long long dec = 0; | ||
debug(dec); | ||
while(data!=0){ | ||
dec += (data%10)*pow(2,len); | ||
len++; | ||
data /= 10; | ||
} | ||
cout<<dec<<endl; | ||
|
||
} | ||
return 0; | ||
} | ||
|
Binary file not shown.
Empty file.
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,82 @@ | ||
// https://youtu.be/8ymiMHQPgZY | ||
#include<bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
|
||
|
||
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) | ||
#define MOD 1000000007 | ||
#define MOD1 998244353 | ||
#define INF 1e18 | ||
#define nline "\n" | ||
#define pb push_back | ||
#define ppb pop_back | ||
#define mp make_pair | ||
#define ff first | ||
#define ss second | ||
#define PI 3.141592653589793238462 | ||
#define set_bits __builtin_popcountll | ||
#define sz(x) ((int)(x).size()) | ||
#define all(x) (x).begin(), (x).end() | ||
|
||
typedef long long ll; | ||
typedef long long int lli; | ||
typedef unsigned long long ull; | ||
typedef long double lld; | ||
// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key | ||
|
||
#ifndef ONLINE_JUDGE | ||
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl; | ||
#else | ||
#define debug(x) | ||
#endif | ||
|
||
void _print(ll t) {cerr << t;} | ||
void _print(int t) {cerr << t;} | ||
void _print(string t) {cerr << t;} | ||
void _print(char t) {cerr << t;} | ||
void _print(lld t) {cerr << t;} | ||
void _print(double t) {cerr << t;} | ||
void _print(ull t) {cerr << t;} | ||
|
||
template <class T, class V> void _print(pair <T, V> p); | ||
template <class T> void _print(vector <T> v); | ||
template <class T> void _print(set <T> v); | ||
template <class T, class V> void _print(map <T, V> v); | ||
template <class T> void _print(multiset <T> v); | ||
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";} | ||
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} | ||
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} | ||
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} | ||
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} | ||
|
||
int main() { | ||
#ifndef ONLINE_JUDGE | ||
freopen("errorf.in", "w", stderr); | ||
#endif | ||
fastio(); | ||
int start=0; | ||
int end = 0; | ||
int gap=0; | ||
cin>>start; | ||
cin>>end; | ||
cin>>gap; | ||
debug(start); | ||
debug(end); | ||
debug(gap); | ||
for(int i=start;i<=end;i+=gap){ | ||
// https://stackoverflow.com/questions/27971967/c-does-not-take-5-9-and-seems-to-typecast-it | ||
// if you do 5/9 then its a integer devide so it will give you 0, if u need to do it in floating | ||
// way,do this | ||
/* | ||
5 // int | ||
5l // long | ||
5.0 // double | ||
5.0f // float | ||
5ul // unsigned long | ||
*/ | ||
cout<<i<<"\t"<<(int)((5.0f/9.0f)*(i-32))<<nline; | ||
} | ||
// cout<<(5/9)*(20-32); | ||
} |
Binary file not shown.
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 @@ | ||
4 |
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,3 @@ | ||
0 | ||
100 | ||
20 |
Empty file.
Empty file.
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,78 @@ | ||
// https://youtu.be/8ymiMHQPgZY | ||
#include<bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
|
||
|
||
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) | ||
#define MOD 1000000007 | ||
#define MOD1 998244353 | ||
#define INF 1e18 | ||
#define nline "\n" | ||
#define pb push_back | ||
#define ppb pop_back | ||
#define mp make_pair | ||
#define ff first | ||
#define ss second | ||
#define PI 3.141592653589793238462 | ||
#define set_bits __builtin_popcountll | ||
#define sz(x) ((int)(x).size()) | ||
#define all(x) (x).begin(), (x).end() | ||
|
||
typedef long long ll; | ||
typedef long long int lli; | ||
typedef unsigned long long ull; | ||
typedef long double lld; | ||
// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key | ||
|
||
#ifndef ONLINE_JUDGE | ||
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl; | ||
#else | ||
#define debug(x) | ||
#endif | ||
|
||
void _print(ll t) {cerr << t;} | ||
void _print(int t) {cerr << t;} | ||
void _print(string t) {cerr << t;} | ||
void _print(char t) {cerr << t;} | ||
void _print(lld t) {cerr << t;} | ||
void _print(double t) {cerr << t;} | ||
void _print(ull t) {cerr << t;} | ||
|
||
template <class T, class V> void _print(pair <T, V> p); | ||
template <class T> void _print(vector <T> v); | ||
template <class T> void _print(set <T> v); | ||
template <class T, class V> void _print(map <T, V> v); | ||
template <class T> void _print(multiset <T> v); | ||
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";} | ||
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} | ||
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} | ||
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} | ||
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} | ||
|
||
int main() { | ||
#ifndef ONLINE_JUDGE | ||
freopen("errorf.in", "w", stderr); | ||
#endif | ||
fastio(); | ||
ll data; | ||
cin>>data; | ||
|
||
if(data==0||data==1){ | ||
cout<<"-1"; | ||
} | ||
else if (data%2==0){ | ||
/* code */ | ||
int val = (data*data)/4; | ||
cout<<val-1<<" "<<val+1; | ||
} | ||
|
||
else if(data%2!=0){ | ||
int val = (data*data)+1; | ||
cout<<val/2-1<<" "<<val/2; | ||
} | ||
|
||
return 0; | ||
|
||
} |
Binary file not shown.
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,24 @@ | ||
#!/usr/bin/sh | ||
|
||
# Author : Soumyadip Sarkar | ||
# License = "Feel free to copy, I appreciate if you star 🌟 the repo" | ||
# Github: soumya997 | ||
|
||
# Usage: | ||
# file generator with boilerplate code | ||
|
||
|
||
|
||
|
||
echo "Enter the file name: " # asking user for giving a file name | ||
read file_name # taking file name from user | ||
|
||
touch $file_name # creating the file | ||
|
||
# A single liner for a basic boilerplate | ||
# echo -e "#include<bits/stdc++.h>\nusing namespace std;\nint main(){\n\n\treturn 0;\n}" >> $file_name | ||
|
||
|
||
# comment out the above echo line and uncomment this to take the boiler plate from a cpp file(here its a.cpp) | ||
value=$(<../../template.cpp) # reading the template file | ||
echo -e "$value" >> $file_name # putting the read content in the new file |
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,2 @@ | ||
# Things I learned in: Day_11_to_20/Day_17 | ||
**Note:** use the github provided TOC for navigaing. |
Oops, something went wrong.