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
#include<bits/stdc++.h> | |
using namespace std; | |
int graph[1001][1001]; | |
int visited[1001]; | |
int n,m,num,p,q; | |
int main() | |
{ | |
memset(visited,0,sizeof(visited)); | |
scanf("%d %d",&n,&m); | |
for(int i=0;i<m;i++){ |
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
#include<bits/stdc++.h> | |
using namespace std; | |
char str[1001]; | |
int a,b,tot; | |
int check(int i,int j) | |
{ | |
int a1=i; | |
int b1=j; | |
while(i<j){ | |
if(str[i]!=str[j]){ |
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
#include<bits/stdc++.h> | |
using namespace std; | |
int arr[21]; | |
int minvalue; | |
int size; | |
int find(int current,int sum,int sum1) | |
{ | |
if(current==size){ | |
if((abs(sum-sum1))<minvalue){ | |
minvalue=abs(sum-sum1); |
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
#include<bits/stdc++.h> | |
using namespace std; | |
int EXP(int x,unsigned int n) | |
{ | |
int temp; | |
if(n==0){ | |
return 1; | |
} | |
if(n==1){ | |
return x; |
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
#include<bits/stdc++.h> | |
using namespace std; | |
class Graph | |
{ | |
int V; | |
list<int> *adj; | |
void toposort(int v,bool visited[],stack<int> &stack); | |
public: | |
Graph(int V); | |
void addEdge(int v,int w); |
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
//A magic number is defined as a number which can be expressed as a power of 5 or sum of unique powers of 5. | |
#include<bits/stdc++.h> | |
using namespace std; | |
int nthMagic(int num) | |
{ | |
int res=0; | |
int p=1; | |
while(num){ | |
p*=5; | |
if(num&1){ |
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
//Author: Krypton3 | |
//Basic but need implementation. | |
//Help: http://www.geeksforgeeks.org/majority-element/ | |
#include<bits/stdc++.h> | |
using namespace std; | |
int main() | |
{ | |
int s = 0, num = 0, majority = 0, c = 1; | |
cin>>s>>majority; |
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
//Author: Krypton3 | |
import java.util.Scanner; | |
public class uva10550{ | |
public static void main(String[] args){ | |
Scanner key=new Scanner(System.in); | |
while(true){ | |
int a=key.nextInt(), b=key.nextInt(),c=key.nextInt(),d=key.nextInt(); | |
if(a==0 && b==0 && c==0 && d==0){ | |
break; | |
} |
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
//Author: Krypton3 | |
import java.util.*; | |
public class uva846{ | |
public static void main(String args[]){ | |
Scanner in=new Scanner(System.in); | |
int test=in.nextInt(); | |
while(test-->0){ | |
int x=in.nextInt(),y=in.nextInt(); | |
int dist=y-x; | |
int steps=0; |
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
//Author: Krypton3 and Rony_ghost | |
//Basic Math | |
#include <bits/stdc++.h> | |
using namespace std; | |
int main(){ | |
int n,t=1,ans; | |
while(scanf("%d",&n)==1){ | |
if(n==0)break; |