USACO 代码仓库
qa15948035838
这个作者很懒,什么都没留下…
展开
-
1.1.4
<br />/* ID: zhangzz4 PROG: gift1 LANG: C++ */ #include<stdio.h> #include<string.h> #include<stdlib.h> int cur[11]; char name[11][16]; int num(char *s) { int i=0; for(;strcmp(name[i],s);i++) ; return i; } int main() { freo原创 2010-08-08 22:19:00 · 344 阅读 · 0 评论 -
USACO 2.2 Subset Sums
<br />/* ID: zhangzz4 PROG: subset LANG: C++ */ #include<stdio.h> const int N=40; int f[N*N/2][N]; int main() { freopen("subset.in","r",stdin); freopen("subset.out","w",stdout); int n; scanf("%d",&n); int sum=n*(n+1)/2;原创 2010-09-13 07:29:00 · 304 阅读 · 0 评论 -
usaco 2.1.3 Ordered Fractions
<br />/* ID: zhangzz4 PROG: frac1 LANG: C++ */ #include<stdio.h> #include<stdlib.h> const int N=161; int v[N][N]; struct Frac { int d1,d2; double f; }f[N*N]; int n; int gcd(int a,int b){return b?gcd(b,a%b):a;} int cmp(const vo原创 2010-08-20 06:37:00 · 234 阅读 · 0 评论 -
1.5.3 SuperPrime Rib
/* ID: zhangzz4 PROG: pprime LANG: C++ */ #include #include int a,b; int ok(int x) { if(xb) return 0; if(x原创 2010-08-19 11:09:00 · 266 阅读 · 0 评论 -
2.1.6 Hamming Codes
<br />/* ID: zhangzz4 PROG: hamming LANG: C++ */ #include<stdio.h> int hamming(int a,int b) { int ans=0; for(int i=0;i<8;i++) if((a&(1<<i))!=(b&(1<<i))) ans++; return ans; } int main() { freopen("hammin原创 2010-08-20 10:00:00 · 286 阅读 · 0 评论 -
2.1.4 Sorting A Three-Valued Sequence
<br />/* ID: zhangzz4 PROG: sort3 LANG: C++ */ #include<stdio.h> const int N=1001; int _min(int a,int b){return a>b?b:a;} int a[N]; int main() { freopen("sort3.in","r",stdin); freopen("sort3.out","w",stdout); int n,n1=0,n2=0;原创 2010-08-20 07:47:00 · 272 阅读 · 0 评论 -
There are 常数s 和 常数s! Usaco 1.5.4 Checker Challenge
<br />/* ID: zhangzz4 PROG: checker LANG: C++ */ #include<stdio.h> #include<time.h> const int N=13; int v[N],cnt,n; int _abs(int a){return a>0?a:-a;} int vv[N],vv2[2*N],vv3[2*N]; void put(int x) { if(!x) return; put(x/10); put原创 2010-08-19 20:18:00 · 239 阅读 · 0 评论 -
1.3.2 Barn Repair
<br />/* ID: zhangzz4 PROG: barn1 LANG: C++ */ #include<stdio.h> #include<string.h> #include<stdlib.h> int cmp(const void *a,const void *b) { return *(int *)b - *(int *)a; } int main() { freopen("barn1.in","r",stdin); freopen("ba原创 2010-08-12 07:47:00 · 281 阅读 · 0 评论 -
1.3.1 Mixing Milk
<br />/* ID: zhangzz4 PROG: milk LANG: C++ */ #include<stdio.h> #include<string.h> #include<stdlib.h> struct Node { int p,a; }d[5001]; int cmp(const void *a,const void *b) { return ((Node *)a)->p - ((Node *)b)->p; } int main() {原创 2010-08-12 07:18:00 · 199 阅读 · 0 评论 -
1.2.5 Dual Palindromes
/* ID: zhangzz4 PROG: dualpal LANG: C++ */ #include #include #include char bc[]={"0123456789ABCDEFGHIJKL"}; void changB(char *s,int n,int b) { int cnt=0; while(n) { s[cnt++]=bc[n%b]; n/=b; } s[c原创 2010-08-11 07:43:00 · 230 阅读 · 0 评论 -
1.2.4 Palindromic Squares
/* ID: zhangzz4 PROG: palsquare LANG: C++ */ #include #include #include char bc[]={"0123456789ABCDEFGHIJKL"}; void changB(char *s,int n,int b) { int cnt=0; while(n) { s[cnt++]=bc[n%b]; n/=b; } s原创 2010-08-11 07:33:00 · 253 阅读 · 0 评论 -
SECTION 2.2 Preface Numbering
<br />/* ID: zhangzz4 PROG: preface LANG: C++ */ #include<stdio.h> #include<string.h> const char L[]={"IVXLCDM"}; int f[8]; void add(int x) { int ten=1,b=0; for(int i=0;i<4;i++,b+=2) { int d=x/ten%10; ten*=原创 2010-09-12 07:33:00 · 252 阅读 · 0 评论