Skip to content

Instantly share code, notes, and snippets.

View Krypton3's full-sized avatar
🏠
Working from home

H. M. Mahedi Hasan Krypton3

🏠
Working from home
View GitHub Profile
@Krypton3
Krypton3 / uva406
Created November 16, 2015 18:48
Prime Number
#include<bits/stdc++.h>
using namespace std;
#define size 1001
int primes[size];
void seive()
{
memset(primes,1,sizeof(primes));
for(int i=2;i<size;i++){
if(primes[i]){
for(int j=2*i;j<size;j+=i){
@Krypton3
Krypton3 / uva 11137
Created October 18, 2015 07:30
Coin Change
#include<bits/stdc++.h>
using namespace std;
long long dp[10001];
int coin[]={1,8,27,64,125,216,343,512,729,1000,1331,1728,2197,2744,3375,4096,4913,5832,6859,8000,9261};
int main()
{
int n;
while(scanf("%d",&n)==1){
memset(dp, 0, sizeof dp); dp[0] = 1;
for(int i = 0; i < 21; i++) {
@Krypton3
Krypton3 / Base Conversion
Created October 15, 2015 07:47
Base Conversion
#include<bits/stdc++.h>
using namespace std;
int main()
{
int test,num,b,x,y;
cin>>test;
for(int p=1;p<=test;p++){
cin>>num>>b>>x>>y;
int sum=0;
int c=1;
#include<bits/stdc++.h>
using namespace std;
int bitTree[100002];
struct contestRank
{
int c1,c2,c3;
};
bool cmp(const contestRank &a,const contestRank &b)
{
return a.c1<b.c1;
@Krypton3
Krypton3 / Uva 544
Created October 6, 2015 05:22
Kruskal Algorithm
#include<bits/stdc++.h>
using namespace std;
map<string,string> parent;
struct Data
{
string u,v;
int w;
};
bool cmp(Data a,Data b)
{
@Krypton3
Krypton3 / UVA-821
Created October 4, 2015 11:16
All pair shortest path - Floyd Warshall
#include<bits/stdc++.h>
using namespace std;
#define MAX 102
#define INF 1000000
int arr[MAX][MAX];
int main()
{
int u,v,cot=0;
while(true){
scanf("%d %d",&u,&v);
@Krypton3
Krypton3 / HORRIBLE - Horrible Queries
Created October 2, 2015 17:51
Lazy Propagation - segment tree
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
int arr[MAX];
int tree[3*MAX];
int lazy[3*MAX];
void build_tree(int node,int a,int b)
{
@Krypton3
Krypton3 / UVA-336
Created September 15, 2015 11:38
A Node Too Far (BFS)
#include<bits/stdc++.h>
using namespace std;
vector<long long >lis[100000];
map<long long,int> check;
map<long long,int> diff;
map<long long,int> visit;
queue<long long> jis;
int bfs(int start,int dist)
{
@Krypton3
Krypton3 / 11060 - Beverages
Created September 8, 2015 14:37
Topological Sort Implementation Faster Approach
#include<bits/stdc++.h>
using namespace std;
#define getint(a) scanf("%d", &a)
map<string,int> pos;
vector<string> str;
int arr[101];
list<int> *adj;
int main()
{
int number,relate,a,b;
@Krypton3
Krypton3 / TIMUS1748
Created September 8, 2015 05:51
Prime Seive and Optimization.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int prime[]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
ll n,number,divisor;
void dfs(int pos,ll num,int div, int limit)
{
if(div>divisor || (div==divisor && num<number)){