Skip to content

Instantly share code, notes, and snippets.

bool DFS( int now, int cnt ) {
visit[ now ] = 1;
bool ret = 0;
if ( now == tgA )
ret = BFS( 1 );
if ( !cnt || ret ) {
visit[ now ] = 0;
return ret;
}
@kuoe0
kuoe0 / sieve.cpp
Last active September 29, 2015 11:38
[Prime] Sieve of Eratosthenes - http://kuoe0.ch/1209/prime-sieve-of-eratosthenes/
#include <cstdio>
#include <cstdlib>
using namespace std;
#define MAX 1000000
bool isNotPrime[ MAX + 1 ];
void sieve() {
memset( isNotPrime, 0, sizeof( isNotPrime ) );
isNotPrime[ 0 ] = isNotPrime[ 1 ] = 1;
for ( int i = 2; i <= MAX; i += 2 )
isNotPrime[ i ] = 1;
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
long long int MAX;
long long int count( int x ) {
if ( x == 1 )
return 0;
const char* toExcelColumnName( int n ) {
string ret = "";
while ( n ) {
int x = n % 26;
if ( x )
ret += 'A' + x - 1;
else
ret += 'Z', n -= 26;
n /= 26;
}
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
int main()
{
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
#define MAXN 110
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
struct POINT {
int x;
bool end;
double c;
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
int pos[ 10010 ];
int main() {
int n;
#include <iostream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
struct POINT {
int x, y;
bool operator< ( const POINT r ) const {
return ( x < r.x ) || ( x == r.x && y < r.y );
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
#define MAXN 50
vector< vector< int > > vertex, rev;
int in[ MAXN ], out[ MAXN ], visit[ MAXN ];
int n, e;
vector< int > topo;