ACM
文章平均质量分 53
黯淡蓝点
这个作者很懒,什么都没留下…
展开
-
UVA - 579 - ClockHands
#include/*12:00为起点,时针转过角度-分针转过角度即可,处理时注意输出<=180*/int main(){ int H,M; double angle,ha,ma; while(scanf("%d:%d",&H,&M)&&(H!=0||M!=0)) { angle=0; printf("%d:%d\n",H,M);原创 2012-08-29 21:38:22 · 254 阅读 · 0 评论 -
UVA - 10112 - Myacm Triangles
#include#include/*由于数据量较小,利用穷举即可,判断一个点是否在三角形内部时,用面积策略容易实现*/double AcquireS(double x1,double x2,double x3,double y1,double y2,double y3){ return fabs(0.5*((y3 - y1)*(x2 - x1)-(y2 - y1)*(x3 - x1原创 2012-08-29 21:41:18 · 328 阅读 · 0 评论 -
UVA - 10387 - Billiard
//镜面反射,画画图,找到角度与路程的关系即可得解#include#include#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286 int main(){ double a,b,s,m,n; double A,velocity,route;原创 2012-08-29 21:40:37 · 362 阅读 · 0 评论 -
UVA - 10250 - The Other Two Trees
/*即为已知正方形的对点,求另外两个点,注意精度,float的精度是不够的*/#include#includedouble Dis(double x1,double y1,double x2,double y2){ return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);} int main(){ double ax1,ay1,ax2,ay原创 2012-08-29 21:37:41 · 293 阅读 · 0 评论 -
UVA - 375 - Inscribed Circles and Isosceles Triangles
/*利用角度求解*/#include#include#define MIN 0.000001#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286int main(){ double B,H,C,sum,r,a,temp; int i,j,n;原创 2012-08-29 21:39:01 · 348 阅读 · 0 评论 -
UVA - 185 - Roman Numerals
/*1.转换数字 2.判断罗马等式 3.回溯穷举阿拉伯等式,统计、输出 耗时一天,自己做出来了,很爽。WA了两次,原因:一开始理解错题意,还以为不考虑0Assume that zero will never appear on its own or as a leading digit, and that no two Roman numerals map onto the same Ar原创 2012-09-02 11:35:19 · 579 阅读 · 0 评论 -
UVA - 350 - Pseudo-Random Numbers
#include#include#include#define max 10000int a[max];int cmp_int(const void *a,const void *b){ int *_a=(int *)a; int *_b=(int *)b; return *_a-*_b;} int main(){ freopen("in.t原创 2012-08-26 11:11:49 · 350 阅读 · 0 评论 -
UVA - 573 - The Snail
#include #includeint Judge(const double h,const double u,const double d,const double f,int &day){ double i=0; double IH=0,DC=0,HAC=0,HAS=0; do { IH=HAS;//printf("IH=%lf ",IH原创 2012-08-24 22:34:59 · 326 阅读 · 0 评论 -
UVA - 10499 - The Land of Justice
#includeint main(){ long long N; while(scanf("%lld",&N)&&N>0) { if(N==1)printf("0%%\n"); else printf("%lld%%\n",N*25); } return 0;}原创 2012-08-24 22:32:45 · 383 阅读 · 0 评论 -
UVA - 591 - Box of Bricks
#include #includeint Rearrange(int h[],int n){ int average,sum=0,step=0; for(int i=0;i<n;i++) { sum+=h[i]; } average=sum/n; for(int i=0;i<n;i++) { if(h[i原创 2012-08-24 22:25:28 · 370 阅读 · 0 评论 -
UVA - 10916 - Factstone Benchmark
//使用备忘录,加快运算速度 #include#includeint a[30]={0};int main(){ long long len,year,i; double s; while(scanf("%lld",&year)&&year) { s=0;i=1; year=(year-1960)/10+2;原创 2012-08-24 22:28:24 · 275 阅读 · 0 评论 -
UVA - 10177 - (2/3/4)-D Sqr/Rects/Cubes/Boxes?
#include/*四次方求和可以由(N+1)^5-n^5,n从1到k推出*/long long Cet(int n,int m){ return n*(n-1)/2; } int main(){ long long n; long long S2,R2,S3,R3,S4,R4,t; while(scanf("%lld",&n)!=EOF)原创 2012-08-24 22:29:16 · 879 阅读 · 0 评论 -
UVA - 10719 - Quotient Polynomial
#include#include#include#include/*atol函数使用时需谨慎,尽量从简,题目输入格式标准化时,写出符合输入格式的SCANF,根据输入读取数值*/int main(){ int i,j,k,tag,s; int a[10005],b[10005]; char c; while(scanf("%d",&k)!=EOF)原创 2012-08-24 22:30:04 · 355 阅读 · 0 评论 -
10790 - How Many Points of Intersection?
/*推理法*/#includeint main(){ long long a,b,p; int c=0; while(scanf("%lld%lld",&a,&b)&&a&&b) { c++; p=a*(a-1)*b*(b-1)/4; printf("Case %d: %lld\n",c,p); }原创 2012-08-24 22:31:28 · 286 阅读 · 0 评论 -
UVA - 10161 - Ant on a Chessboard
#includeint main(){ long long x,n,i,mid,mx,my,ox,oy; while(scanf("%lld",&x)&&x!=0) { if(x==1)printf("1 1\n"); else { for(i=1;i<2100000000;i++) {原创 2012-08-24 22:23:02 · 256 阅读 · 0 评论 -
UVA - 10106 - Product
#include#include#include#include#includeusing namespace std;const int maxn=1000;struct bign{ int len,s[maxn]; bign() { memset(s,0,sizeof(s)); len=1; } bign原创 2012-08-23 22:18:07 · 244 阅读 · 0 评论 -
UVA - 537 - Artificial Intelligence?
#include#include#include#include//#define LOCALint GetValue(char a[],float &p,float &u,float &i){ int il,j=0,k=0,flag[3],tag[2],tg=0,lennm=0,count[3]={0},cnum=0; float save; char num原创 2012-08-22 22:44:23 · 226 阅读 · 0 评论 -
UVA - 10878 - Decode the tape
/*Decode the tape 在很多次RUNTIME ERROR后终于AC了!失败原因:数组开得太大,没有优化代码,浪费了大量空间。*/#include#include#define LOCALint btod(char c[],int n){ if(n==0) return (c[0]-48); else return (c[n]-48)+2*btod(c,n-原创 2012-08-22 22:46:27 · 244 阅读 · 0 评论 -
UVA - 10115 - Automatic Editing
#include#includeint Edit(const char f[],const char re[],char txt[]){ int i,j,k,pos,sv=0; char *c,*t,save[300]; c=strstr(txt,f); if(!c)return 0; t=txt; for(i=0;i<strlen(txt);原创 2012-08-22 23:21:33 · 223 阅读 · 0 评论 -
UVA - 10071 - Back to High School Physics
直接套公式即可。#include int main(){ int v,t,d=0; while((scanf("%d%d",&v,&t))!=EOF) { printf("%d\n",v*t*2); } return 0;}原创 2012-08-21 23:10:32 · 214 阅读 · 0 评论 -
UVA - 408 - Uniform Generator
#include#include/*实际上是求最大公约数*/int gys(int a,int b){ int t; if(a<b) { t=a; a=b; b=t; } while(b!=0) { t=a%b; a=b;原创 2012-08-26 11:11:05 · 339 阅读 · 0 评论 -
UVA - 568 - Just the Facts
/*一开始想简单了,导致25!=150,其实还有进位,保留最后五位数就没问题了!注意%的使用*/#includeint main(){ int a[10001],N,i,j; a[0]=1; for(i=1;i<10001;i++) { a[i]=a[i-1]*i; if(a[i]%10000==0)a[i]/=10000;原创 2012-08-26 11:10:30 · 318 阅读 · 0 评论 -
UVA - 550 - Multiplying by Rotation
#include#include//题意即为给出a0和乘数及数制,然后求出到an的最小循环数组长度//例如:179487*4=717948;179487179487*4=717948717948,则答案为6int Acquire(const int base,int a,const int factor){ int i=1,j,k; k=a; do {原创 2012-08-26 11:09:55 · 294 阅读 · 0 评论 -
UVA - 575 - Skew Binary
#include#includeint main(){ freopen("575in.txt","r",stdin); freopen("575out.txt","w",stdout); char a[100]; int n,i,j,sum,x; memset(a,0,sizeof(a)); while(gets(a)&&a[0]!='0')原创 2012-08-26 11:07:53 · 247 阅读 · 0 评论 -
UVA - 10025 - The ? 1 ? 2 ? ... ? n = k problem
#include#includeint main(){ int sum,x,t,i,n,k; scanf("%d",&t); for(k=0;k<t;k++) { sum=0; scanf("%d",&x); if(x<0)x=-x; for(i=0;i<10000;i++) {原创 2012-08-24 22:24:54 · 1980 阅读 · 1 评论 -
UVA - 107 - The Cat in the Hat
#include#include#includeint main(){ //freopen("107in.txt","r",stdin); //freopen("1077out.txt","w",stdout); double H,worker,depth,N,mid; int mul,catH,sumH,sumC; while(scanf("%lf原创 2012-08-24 22:26:07 · 338 阅读 · 0 评论 -
UVA - 10970 - Big Chocolate
#includeint main(){ int x,y; while(scanf("%d%d",&x,&y)!=EOF) { printf("%d\n",x*y-1); } return 0;}原创 2012-08-24 22:27:45 · 325 阅读 · 0 评论 -
UVA - 253 - Cube painting
#include//穷举法 #includeint rot[12][6]={{1,2,3,4,5,6},{1,3,5,2,4,6},{1,4,2,5,3,6},{1,5,4,3,2,6},\{2,1,4,3,6,5},{2,3,1,6,4,5},{2,4,6,1,3,5},{2,6,3,4,1,5},\{3,1,2,5,6,4},{3,2,6,1,5,4},{3,5,1,6,2,4},{3原创 2012-08-24 22:23:41 · 1445 阅读 · 0 评论 -
UVA - 152 - Tree's a Crowd
#include#include#include#include#includetypedef struct tree{ int x,y,z;}; double dis(tree a,tree b){ double i,j,k,sum; i=a.x-b.x; j=a.y-b.y; k=a.z-b.z; sum=i*i+j*j+k*k;原创 2012-08-23 22:24:25 · 534 阅读 · 0 评论 -
UVA - 755 - 487--3279
#include#include#include#includechar PhoneNumber[100000][30];int Count[100000];int cmp_string(const void *_a,const void *_b){ char *a=(char *)_a; char *b=(char *)_b; return strcmp(a原创 2012-08-23 22:29:04 · 320 阅读 · 0 评论 -
UVA - 10785 - The Mad Numerologist
#include#include#includeint cmp_char(const void *_a,const void *_b){ char *a=(char *)_a; char *b=(char *)_b; return *a-*b;} int main(){ char vowel[106],consonant[106],name[23原创 2012-08-23 22:31:03 · 249 阅读 · 0 评论 -
UVA - 424 - Integer Inquiry
#include#include#include#include#includeusing namespace std;const int maxn=1000;struct bign{ int len,s[maxn]; bign() { memset(s,0,sizeof(s)); len=1; } bign原创 2012-08-23 22:10:50 · 254 阅读 · 0 评论 -
UVA - 748 - Exponentiation
#include//如果输出是整数,不要输出小数点。#include#include#include#includeusing namespace std;const int maxn=1000;struct bign{ int len,s[maxn]; bign() { memset(s,0,sizeof(s)); len=原创 2012-08-23 22:13:12 · 261 阅读 · 0 评论 -
UVA - 10494 - If We Were a Child Again
#include#include#include#include#include//必须使用高精度除法和求模 using namespace std;const int maxn=1000;struct bign{ int len,s[maxn]; bign() { memset(s,0,sizeof(s)); len=1;原创 2012-08-23 22:13:50 · 318 阅读 · 0 评论 -
UVA - 465 - Overflow
#include//*#include#include#include#includeusing namespace std;const int maxn=1000;struct bign{ int len,s[maxn]; bign() { memset(s,0,sizeof(s)); len=1; } bi原创 2012-08-23 22:14:43 · 200 阅读 · 0 评论 -
UVA - 401 - Palindromes
#include#includeint main(){ int i,j=1,k,count=0,flag[200]={0},judge=0,len; char a[200]={0}; while(scanf("%s",a)!=EOF) { j=1; count=0; judge=0; for(k=原创 2012-08-22 22:41:31 · 224 阅读 · 0 评论 -
UVA - 10010 - Where's Waldorf?
/*Where's Waldorf用暴力求解解决了,但是花了两天的时间,关键是if条件没写清楚,期间对scanf的理解也加深了,各种输入最好不要混用。另外还要注意题意,最后一行输出不要多打回车!看了一下别人78行的代码,把我的16个If条件句全部浓缩到一个二维向量里去了,我的代码重复率太高,原来利用数组下标就可以了。*/#include#include#include#define原创 2012-08-22 22:42:20 · 593 阅读 · 0 评论 -
UVA - 10361 - Automatic Poetry
#include#include//#define LOCALint main(){ #ifdef LOCAL freopen("in.txt","r",stdin); freopen("ou.txt","w",stdout); #endif int n,i,j,k,t=0,s=0,flag[4]={0}; char sf[105],ss[1原创 2012-08-22 22:43:32 · 255 阅读 · 0 评论 -
UVA - 409 - Excuses, Excuses!
#include#include#includeint Find(char a[],char b[]){ if(strcmp(a,b)==0) return 1; else return 0;} int main(){ #ifdef LOCAL freopen("409in.txt","r",stdin); fre原创 2012-08-22 22:45:08 · 282 阅读 · 0 评论 -
UVA - 10815 - Andy's First Dictionary
#include#include#include#include#define LOCALchar word[100000][250];int cmp_string(const void* _a,const void* _b){ char* a=(char*)_a; char* b=(char*)_b; return strcmp(a,b);} vo原创 2012-08-22 22:48:06 · 490 阅读 · 0 评论