无聊参加了一下北航的比赛,130多名吧  他们大一好多高手 我还是努力学习吧!

题目链接:http://acm.buaa.edu.cn/contest/63/problem/

作者解题报告:http://blog.csdn.net/dslovemz/article/details/8310089

题目 A:掷骰子

题目类型:简单概率

题目知识点 :排序  简单分配

解题目过程:一看求期望值就觉得是个简单的题目,算了两个例子就知道是从小到大排,然后分配给每一个筛子。然后期望值酒是最小的了

代码如下

View Code

题目 B:Taylor公式

题目类型:简单公式运用

题目知识点:浮点误差

解题过程:开始是用math.h里面的公式来的,然后测试一看,不是2012就是2011 然后就直接输出2012看看,没想到过了

附作者解题思路:

由tan(a+b) = (tan(a)+tan(b))/(1-tan(a)*tan(b))得
1/a = tan(arctan(1/b)+arctan(1/c)) = (1/b+1/c)/(1-1/b*1/c) = (b+c)/(cb-1)
=>cb-1=ab+ac => b*c-a*b-c*a=1
故ans = 2012/1 = 2012

代码如下:

View Code
 1 #include <stdio.h>
 2 #include <math.h>
 3 int main()
 4 {
 5    int  n,i;
 6     scanf("%d",&n);
 7    for (i = 1 ; i <=  n ; i ++)
 8    {
 9        int a,b;
10        double c;
11       scanf("%d %d",&a,&b);
12    
13       printf("2012\n");
14    }
15    return 0 ;
16 
17 }

题目C:得了多少奖

题目类型:字符串分析

题目知识点:字符串查找 字符串处理 指针处理

解题过程 :耗费了很多时间 发现在给出的页面边上就有一个得奖页面,将字符串按【分段 然后再用指针查找 最后打表 就可以直接输出了

代码如下:

View Code
 1 #include <stdio.h>
 2 #include <string.h>
 3 struct st
 4 {
 5     char num[20];
 6     int a,b,c,d;
 7 
 8 };
 9 int main()
10 {
11    struct st a[ ]={{"34060609",0,0,1,0},{"34060814",1,0,0,0},{"35060616",0,0,2,1},{"35060622",2,5,2,0},{"35060722",0,1,2,1},{"35090209",0,1,0,0},{"35211219",0,1,1,1},{"35211231",0,1,1,1},{"35211312",1,3,0,0},{"35211425",2,3,2,0},{"35230107",0,0,2,0},{"35230115",0,0,1,1},{"SY0906111",0,2,0,0},{"SY0906226",0,1,1,0},{"36030411",0,1,3,1},{"36060415",0,0,1,0},{"36060610",0,1,2,0},{"36090119",0,0,2,0},{"36091223",0,1,2,0},{"36093117",0,0,1,0},{"36211309",0,4,2,0},{"36211409",0,1,2,0},{"36211420",0,2,1,0},{"36230116",0,0,1,0},{"37060221",0,2,1,0},{"37071426",0,0,0,1},{"37211126",0,0,0,2},{"37211525",0,0,0,1},{"37211226",0,1,0,0},{"38022626",0,0,0,1},{"38211114",0,0,0,1},{"38211212",1,6,0,0},{"38211219",0,2,0,1},{"38211313",0,0,0,1},{"38211314",1,5,0,0},{"38211316",0,2,0,0},{"38211324",0,0,1,1},{"38211406",0,0,1,1},{"38211416",0,0,1,0},{"38211424",0,0,1,0},{"38211503",0,0,1,1},{"38211516",0,0,1,0},{"38230210",0,1,0,1},{"38230214",0,1,0,0},{"39055104",0,3,1,0},{"39061124",0,0,1,0},{"39061326",0,0,1,0},{"39061328",0,0,1,0},{"39061412",0,0,1,1},{"39061512",1,3,1,1},{"39211108",0,1,0,1},{"39211306",0,0,0,1},{"39211509",0,2,1,1},{"39231214",0,1,0,1},{"10061023",0,1,2,0},{"10061061",0,1,2,0},{"10061189",0,0,2,0},{"10061210",0,0,1,0},{"10091234",0,1,3,0},{"10131061",0,1,0,0},{"10131064",0,1,0,0},{"10211031",0,1,3,0},{"10211072",0,1,3,0},{"11061214",0,0,2,0},{"11061215",0,0,2,0},{"11211078",0,0,2,0},{"11211104",0,0,2,0},{"11211116",0,0,2,0},{"11211119",1,1,0,0}};    
12    int i,j,k;
13    char c[20];
14    while (gets(c))
15    {
16    for (i = 0 ; i <= 68 ; i ++ )
17      if (strcmp(c,a[i].num) == 0)
18          printf("%dAu %dAg %dCu %dFe\n", a[i].a, a[i].b,a[i].c,a[i].d);
19    
20    }
21    return 0;
22 }

题目D:GGCD

题目类型:数论

题目知识点:任何一个数都能用质数的幂相加而得到

题目描述:输入两个数 A B 求gcd(A,B^B);

解题过程:开始一直以为是边乘边gcd然后判断,后来钦哥看了一下就给出解法了

解题思路:先将质数存数组,然后用另两个数组分别代表A 和  B 的每个质数因子的情况;然后將B的情况乘以B;然后他们公共的质数因子就是他们的最大公约数;

代码如下:

View Code
 1 #include <stdio.h>
 2 #include <math.h>
 3 int min(int x, int y)
 4 {
 5   return x>=y?y:x;
 6 }
 7 int pw(int n,int t)
 8 {
 9   int i , s = 1;
10   for (i = 1 ; i <= t; i++  )
11       s = s*n;
12    return s;
13 
14 }
15 int main()
16 {
17    int a[11]={2,3,5,7,11,13,17,19,23,29,31};
18    int x,y;
19    while (scanf("%d %d", &x, &y) != EOF)
20    {
21       int i , j , k = 1 ,t = y ; 
22       int c[11]={0},b[11]={0};
23       for(i = 0 ; i < 11 ; i ++)
24       {
25          if(x %a[i] == 0 )
26            {     c[i]++;
27                 x = x / a[i];
28                 i = i - 1;
29            }
30          if (x == 1)
31              break;
32       }
33    for(i = 0 ; i < 11 ; i ++)
34       {
35          if(y % a[i] == 0 )
36            {     b[i]++;
37                 y = y / a[i];
38                 i = i - 1;
39            }
40          if (y == 1)
41              break;
42          
43       }
44       for (i = 0 ; i < 11; i ++)
45           b[i]=b[i]*t;
46       for (i =0 ; i < 11 ; i ++)
47           k = k*pw(a[i],min(c[i],b[i]));
48         
49       printf("%d\n",k);
50 
51    }
52 return 0;
53 
54 
55 }

其他题目没做

题目K:

和题目C一样 就不多说了;

代码如下:

View Code
 1 #include <stdio.h>
 2 #include <string.h>
 3 char a[1000000]={0};
 4 int main()
 5 { 
 6      int i=0 ;
 7      char c, *p1, *p2;
 8      memset(a ,0 ,sizeof(a));
 9      c = getchar();
10      while (c != EOF)
11      {
12          a[i++] = c;
13          c = getchar ();
14 
15      }
16      p1 = a;
17      while (strstr(p1,"Accepted"))
18       {
19         p1 = strstr(p1,"Accepted") - 628;
20         p2 = strstr(p1,"lang_");
21          p2 = p2+5;
22           
23          while (*p2 != '\'')  
24           {
25            printf("%c", *p2);
26            p2 = p2+1;
27           }
28           printf(" ");
29           p2= strstr(p1,"/problem/");
30           p2 = p2 + 9;
31           p1 = p2;
32         
33           if (*p2 == '\"')
34           { 
35            p2= strstr(p1,"/problem/");
36            p2 = p2 + 9;
37            printf("%c ",*p2);
38           }
39           else
40           printf("%c ",*p2);
41           
42           
43           p2 = strstr(p1,"/profile/") + 9;
44           while (*p2 != '/')  
45           {
46            printf("%c", *p2);
47            p2 = p2+1;
48           }
49           
50         printf("\n");
51         p1 = strstr(p1, "Accepted")+8 ;
52       }
53     
54    return 0 ;
55 
56 }

 

posted on 2012-12-20 19:24  dark_dream  阅读(244)  评论(0编辑  收藏  举报