您正在查看 "Usaco" 分类下的文章
2009-11-09 23:45
/*
LANG: C++
ID: yjyfrom1
PROG: c |
2009-08-01 10:36
卡stl memery size
//start
/*
ID: yjyfrom1
PROG: humble
LANG: C++
*/
#include <stdio.h>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef long long INT64;
const int SIZE = 120;
INT64 MAX = (1LL<<32)-1;
INT64 dat[SIZE];
int k,n;
void init();
INT64 work();
priority_queue<INT64 ,vector<INT64> , greater<INT64> > pq;
int |
2009-07-29 10:08
最小生成树
//start
/*
ID: yjyfrom1
PROG: agrinet
LANG: C++
*/
#include <stdio.h>
#include <string.h>
const int SIZE = 120;
const int INF = 10000000;
int map[SIZE][SIZE];
int used[SIZE];
int cost[SIZE];
void init();
int n;
int prim(int);
void show();
int main(){
freopen("agrinet.in","r",stdin);
freopen("agrinet.out","w",stdout);
init(); |
2009-07-29 09:37
进军 chapter 3
//start
/*
ID: yjyfrom1
PROG: fracdec
LANG: C++
*/
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string.h>
using namespace std;
const int SIZE = 100010;
class Pari{
public:
int rem,val;
Pari(int a=0 ,int b=0){
rem=a;
val=b;
}
void show(){
printf("(%d ,%d )\n",rem,val);
}
}; |
2009-07-26 13:23
/*
ID: yjyfrom1
PROG: comehome
LANG: C++
*/
#include <stdio.h>
const int SIZE = 300;
const int INF =1000000;
int map[SIZE][SIZE];
int node[SIZE];
int id[SIZE];
int sz=0;
void work();
void show();
int main(){
freopen("comehome.in","r",stdin);
freopen("comehome.out","w",stdout);
work();
}
void work(){
int i,j;
sz=0;
for (i='a' ; i<='z' ;i++)
|
2009-07-26 12:54
/*
ID: yjyfrom1
PROG: cowtour
LANG: C++
*/
#include <stdio.h>
#include <math.h>
const int SIZE = 170;
const double INF = 1e20;
bool map[SIZE][SIZE];
double dis[SIZE][SIZE];
double x[SIZE];
double y[SIZE];
double far[SIZE];
double rad[SIZE];
double calc(int ,int);
double init();
void show();
int n;
int main(){
freopen("cowtour.in","r",stdin);
freopen("cowtour.out |
2009-07-22 15:06
控制关系不是 相乘的传递 。
//start
/*
ID: yjyfrom1
PROG: concom
LANG: C++
*/
#include <stdio.h>
#include <string.h>
const int SIZE = 120;
int owns[SIZE][SIZE];
bool con[SIZE][SIZE];
void init();
void work();
void add(int ,int ,int);
void control(int ,int);
int main(){
freopen("concom.in","r",stdin);
freopen("concom.out","w",stdout);
init();
wor |
2009-07-20 19:02
/*
ID: yjyfrom1
LANG: C++
TASK: zerosum
*/
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
const int SIZE = 100;
char buff[SIZE];
int work(int );
int n;
int calc(char *);
vector<string> ans;
int main(){
freopen("zerosum.in","r",stdi |
2009-07-18 10:03
注意取模
//start
/*
ID: yjyfrom1
LANG: C++
TASK: nocows
*/
#include <stdio.h>
#include <string.h>
const int SIZE = 300;
const int MOD = 9901;
int dp[SIZE][SIZE];
int n,k;
void init();
int main(){
freopen("nocows.in","r",stdin);
freopen("nocows.out","w",stdout);
init();
scanf("%d%d",&n,&k);
int tmp =dp[n][k] - dp[n |
2009-07-17 23:59
//start
/*
ID: yjyfrom1
LANG: C++
TASK: prefix
*/
#include <stdio.h>
#include <iostream>
#include <string>
#include <string.h>
#include <map>
using namespace std;
const int SIZE =200100 ;
char txt [SIZE];
int dp[SIZE];
const int WIDTH =30;
class Trie{
public:
bool ed;
Trie * ch[WIDTH];
Trie(){
ed=false;
int i;
for |
2009-07-15 17:15
用 dfs 生成排列 , 是从小到大的 , 判断就ok 了 ,len <=7 , 8 和9 不存在
//start
/*
ID: yjyfrom1
PROG: runround
LANG: C++
*/
#include <string.h>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;
const int SIZE = 362890;
bool used[15];
void init();
char buff[15];
void dfs(int ,int);
bool check(int);
int n;
bool ok=false;
int main(){
fr |
2009-07-15 16:20
分两部分 , 一定是 s = sum(1..n )/2
用背包是思路 , 问1... n 可以组成 s 的方法数 , 记住 除以 2
//start
/*
ID: yjyfrom1
PROG: subset
LANG: C++
*/
#include <stdio.h>
#include <string.h>
typedef unsigned long long INT64 ;
const int SIZE = 400;
INT64 dp[SIZE];
int main(){
freopen("subset.in","r",stdin);
freopen("subset.out","w",stdout);
int n;
scanf("%d |
2009-07-13 12:28
数字 --》 罗马数字 ,
很实用
//start
/*
ID: yjyfrom1
PROG: preface
LANG: C++
*/
#include <stdio.h>
#include <string.h>
char * code[] ={"","I","II","III","IV","V","VI","VII","VIII","IX"};
char buff[50]="";
char str [500]="";
char * romdig(int d , char *base){
char *sp =code[d%10] ;
int |
2009-07-09 10:54
/*
ID: yjyfrom1
PROG: frac1
LANG: C++
*/
#include <stdio.h>
int tot=0;
const int SIZE = 100000;
int f[SIZE][2];
int n;
int cnt;
void mkfarey(int x1 , int y1 , int x2 , int y2);
void show();
int main(){
freopen("frac1.in","r",stdin);
freopen("frac1.out","w",stdout);
scanf("%d",&n);
cnt=1; |
2009-07-09 10:45
要注意位运算的优先级
//start
/*
ID: yjyfrom1
PROG: castle
LANG: C++
*/
#include <stdio.h>
#include <string.h>
const int SIZE = 60;
const int LEN = 4000;
int map[SIZE][SIZE];
int col[SIZE][SIZE];
int area[LEN];
int m,n;
int tot;
void init();
int ar;
void dfs(int x,int y,int c);
bool check(int x,int y);
int deta[][2]={{0,-1}, {-1,0}, {0,1}, {1,0}};
void show();
void connect();
|
|
| |