-
Notifications
You must be signed in to change notification settings - Fork 1
/
mynotes.txt
91 lines (76 loc) · 2.19 KB
/
mynotes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
## C++ Section
- to push a character at back str.push_back('c')
- to append at specific index str.append(index,char)
- .length() to find length of string
- access char at specific index str.at(4)
- s[i]!='\0' can be a helpful terminating condition sometimes ;)
- empty char '\0'
- max=INT_MIN min=INT_MAX
- sort(a,a+n)
- sort(fraction.begin(),fraction.end(),greater<int>()) // sort vector
- cout<<fixed<<setprecision(n)<<; // to give output to n places after decimal.
- abs(x) gives absolute value of x
- to initialize array to 0; int a[x] = {0};//works for double dimentional array as well.
- map<int, int> map1; map<int, int>::iterator itr;
- max_element(v.begin(),v.end()) - v.begin(); //index of max element
- *max_element(v.begin(), v.end()); //value of max element
cses.fi/problemset
Type Typical Bit Width Typical Range
char 1byte -127 to 127 or 0 to 255
unsigned char 1byte 0 to 255
signed char 1byte -127 to 127
int 4bytes -2147483648 to 2147483647
unsigned int 4bytes 0 to 4294967295
signed int 4bytes -2147483648 to 2147483647
short int 2bytes -32768 to 32767
unsigned short int 2bytes 0 to 65,535
signed short int 2bytes -32768 to 32767
long int 8bytes -2,147,483,648 to 2,147,483,647
signed long int 8bytes same as long int
unsigned long int 8bytes 0 to 18,446,744,073,709,551,615
long long int 8bytes -(2^63) to (2^63)-1
unsigned long long int 8bytes 0 to 18,446,744,073,709,551,615
float 4bytes
double 8bytes
long double 12bytes
wchar_t 2 or 4 bytes 1 wide character
# Scrape code maybe::
#include<bits/stdc++.h>
using namespace std;
#define abhinav ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define endl "\n"
#define ll long long int
void solve(){}
int main()
{
abhinav;
int t;
cin>>t;
while(t--)
{
solve();
}
return 0;
}
count number of bits::
ll bitcount(ll n){
ll count = 0;
while (n > 0){
count += 1;
n = n & (n-1);
}
return count;
}
--Binary representation
for i in 30..0
if(x & (1<<i)!=0)
cout<<1;
else
cout<<0;
--GCD of two numbers
if(b==0)
return a;
else if(a>b)
return gcd_fast(b,a%b);
else
return gcd_fast(a,b%a);