├── README.md ├── diehard3.o ├── handshake.o ├── ncr-table.o ├── diehard3.exe ├── filling-jars.o ├── findthepoint.o ├── handshake.exe ├── ncr-table.exe ├── diwali-lights.o ├── filling-jars.exe ├── findthepoint.exe ├── halloweenparty.o ├── minimum-draws.o ├── connectingtowns.exe ├── connectingtowns.o ├── diwali-lights.exe ├── halloweenparty.exe ├── minimum-draws.exe ├── minimum-draws.cpp ├── handshake.cpp ├── findthepoint.cpp ├── filling-jars.cpp ├── halloweenparty.cpp ├── connectingtowns.cpp ├── diehard3.cpp ├── diwali-lights.cpp ├── ncr-table.cpp └── LICENCE /README.md: -------------------------------------------------------------------------------- 1 | # Hazrat Ali 2 | 3 | # Software Engineering 4 | 5 | # HackerRank Mathematics -------------------------------------------------------------------------------- /diehard3.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/diehard3.o -------------------------------------------------------------------------------- /handshake.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/handshake.o -------------------------------------------------------------------------------- /ncr-table.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/ncr-table.o -------------------------------------------------------------------------------- /diehard3.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/diehard3.exe -------------------------------------------------------------------------------- /filling-jars.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/filling-jars.o -------------------------------------------------------------------------------- /findthepoint.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/findthepoint.o -------------------------------------------------------------------------------- /handshake.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/handshake.exe -------------------------------------------------------------------------------- /ncr-table.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/ncr-table.exe -------------------------------------------------------------------------------- /diwali-lights.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/diwali-lights.o -------------------------------------------------------------------------------- /filling-jars.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/filling-jars.exe -------------------------------------------------------------------------------- /findthepoint.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/findthepoint.exe -------------------------------------------------------------------------------- /halloweenparty.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/halloweenparty.o -------------------------------------------------------------------------------- /minimum-draws.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/minimum-draws.o -------------------------------------------------------------------------------- /connectingtowns.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/connectingtowns.exe -------------------------------------------------------------------------------- /connectingtowns.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/connectingtowns.o -------------------------------------------------------------------------------- /diwali-lights.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/diwali-lights.exe -------------------------------------------------------------------------------- /halloweenparty.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/halloweenparty.exe -------------------------------------------------------------------------------- /minimum-draws.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/HackerRank-Mathematics/HEAD/minimum-draws.exe -------------------------------------------------------------------------------- /minimum-draws.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | int t; 9 | cin >> t; 10 | while (t--) 11 | { 12 | int n; 13 | cin >> n; 14 | cout << n + 1 << endl; 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /handshake.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | cin >> n; 9 | while (n--) 10 | { 11 | int n; 12 | cin >> n; 13 | cout << (long long)n * (n - 1) / 2 << endl; 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /findthepoint.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int k; 7 | cin >> k; 8 | while (k--) 9 | { 10 | int mx, my, nx, ny; 11 | cin >> mx >> my >> nx >> ny; 12 | cout << 2 * nx - mx << " " << 2 * ny - my << endl; 13 | } 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /filling-jars.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n, m; 7 | cin >> n >> m; 8 | long long ans = 0; 9 | while (m--) 10 | { 11 | int a, b, k; 12 | cin >> a >> b >> k; 13 | ans += (b - a + 1)*(long long)k; 14 | } 15 | cout << ans / n << endl; 16 | } 17 | -------------------------------------------------------------------------------- /halloweenparty.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int m; 8 | cin >> m; 9 | while (m--) 10 | { 11 | int k; 12 | cin >> k; 13 | if (k % 2 == 1) 14 | { 15 | long long tmp = k / 2; 16 | cout << tmp * (tmp + 1) << endl; 17 | } 18 | else 19 | { 20 | cout << (long long)k * k / 4 << endl; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /connectingtowns.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int t; 7 | cin >> t; 8 | while (t--) 9 | { 10 | int n; 11 | cin >> n; 12 | long long ans = 1; 13 | for (int i = 0; i < n - 1; i++) 14 | { 15 | int num; 16 | cin >> num; 17 | ans = (ans * num) % 1234567; 18 | } 19 | cout << ans << endl; 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /diehard3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int gcd(int a, int b) 5 | { 6 | return b ? gcd(b, a%b) : a; 7 | } 8 | 9 | int main() 10 | { 11 | int d; 12 | cin >> d; 13 | while (d--) 14 | { 15 | int a, b, c; 16 | cin >> a >> b >> c; 17 | if (c % gcd(a, b) == 0 && c <= max(a, b)) 18 | cout << "YES" << endl; 19 | else 20 | cout << "NO" << endl; 21 | } 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /diwali-lights.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int modexp(int a, int b, int mod) 5 | { 6 | long long ret = 1, tmp = a; 7 | while (b) 8 | { 9 | if (b & 1) 10 | ret = (ret * tmp) % mod; 11 | tmp = (tmp * tmp) % mod; 12 | b >>= 1; 13 | } 14 | return ret % mod; 15 | } 16 | 17 | int main() 18 | { 19 | int t; 20 | cin >> t; 21 | while (t--) 22 | { 23 | int n; 24 | cin >> n; 25 | int tmp = modexp(2, n, 100000); 26 | tmp--; 27 | if (tmp == -1) tmp = 99999; 28 | cout << tmp << endl; 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /ncr-table.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int f[1001][1001]; 5 | 6 | void init() 7 | { 8 | f[1][0] = f[1][1] = 1; 9 | for (int i = 2; i <= 1000; i++) 10 | { 11 | f[i][0] = f[i][i] = 1; 12 | for (int j = 1; j < i; j++) 13 | f[i][j] = (f[i - 1][j - 1] + f[i - 1][j]) % 1000000000; 14 | } 15 | } 16 | 17 | int main() 18 | { 19 | init(); 20 | int t; 21 | cin >> t; 22 | while (t--) 23 | { 24 | int n; 25 | cin >> n; 26 | for (int i = 0; i <= n; i++) 27 | cout << f[n][i] << " "; 28 | cout << endl; 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Hazrat Ali 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. --------------------------------------------------------------------------------