[其他] 灵动集训第三天

[复制链接]
2260|39
 楼主| l63t89 发表于 2021-1-28 22:54 | 显示全部楼层
F题 What is the Probability ?
693066012d03637ec0.png
 楼主| l63t89 发表于 2021-1-28 22:55 | 显示全部楼层
思考过程
简单概率题,没有什么难点。
 楼主| l63t89 发表于 2021-1-28 22:56 | 显示全部楼层
源代码
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main()
  4. {
  5.         int t, n, i;
  6.         double p;
  7.         scanf("%d", &t);
  8.         while (t--)
  9.         {
  10.                 scanf("%d%lf%d", &n, &p, &i);
  11.                 printf("%.4f\n", p == 0 ? p : p * pow(1 - p, i - 1) / (1 - pow(1 - p, n)));
  12.         }
  13.         return 0;
  14. }
 楼主| l63t89 发表于 2021-1-28 23:00 | 显示全部楼层
遇到问题
无。
 楼主| l63t89 发表于 2021-1-28 23:02 | 显示全部楼层
G题 Burger
945776012d1f92c4e4.png
 楼主| l63t89 发表于 2021-1-28 23:03 | 显示全部楼层
思考过程
概率题,需要一个反向思维,有点难想,但听了讲解后挺容易理解的。
 楼主| l63t89 发表于 2021-1-28 23:04 | 显示全部楼层
源代码
  1. #include<stdio.h>
  2. #include<string.h>
  3. typedef long long LL;
  4. double dp[100100];
  5. void init()
  6. {
  7.     dp[2]=1.0;
  8.     for(int i=4;i<100100;i+=2)
  9.         dp[i]=dp[i-2]*(i-3)/(i-2);
  10. }
  11. int main()
  12. {
  13.     int n,x;
  14.     scanf("%d",&n);
  15.     init();
  16.     while(n--)
  17.     {
  18.         scanf("%d",&x);
  19.         printf("%.4f\n",1.0-dp[x]);
  20.     }
  21. }
 楼主| l63t89 发表于 2021-1-28 23:05 | 显示全部楼层
遇到问题
反向思考不一定能想到
 楼主| l63t89 发表于 2021-1-28 23:06 | 显示全部楼层
H题 Coin Toss
952046012d2c374365.png
 楼主| l63t89 发表于 2021-1-28 23:07 | 显示全部楼层
 楼主| l63t89 发表于 2021-1-28 23:09 | 显示全部楼层
 楼主| l63t89 发表于 2021-1-28 23:12 | 显示全部楼层
思考过程
一开始没啥思路,但看了一个讲解,只要考虑全面,分号类,就没有那么难了。
 楼主| l63t89 发表于 2021-1-28 23:13 | 显示全部楼层
源代码
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main()
  4. {
  5.     const double PI=acos(-1.0);
  6.     double area[5];
  7.     double n,m,t,c;
  8.     int cas,i,j;
  9.     double d11,d12,d13,d21,d22;
  10.     scanf("%d",&cas);
  11.     for(i=1;i<=cas;i++)
  12.     {
  13.         scanf("%lf%lf%lf%lf",&n,&m,&t,&c);
  14.         d11=(t-c/2)*(t-c/2)*4;
  15.         d12=(t-c/2)*(t-c)*(n+m-4)*2;
  16.         d13=(t-c)*(t-c)*(n*m-(2*(n+m)-4));
  17.         d21=c*(t-c/2)*((m-1)*2+(n-1)*2);
  18.         d22=c*(t-c)*((m-1)*n+(n-1)*m-(m-1)*2-(n-1)*2);
  19.         area[0]=t*t*n*m;
  20.         area[1]=d11+d12+d13;
  21.         area[2]=d21+d22;
  22.         area[3]=(c*c-PI*(c/2)*(c/2))*(n-1)*(m-1);
  23.         area[4]=PI*c*c/4*(n-1)*(m-1);
  24.         printf("Case %d:\n",i);
  25.         for(j=1;j<=4;j++)
  26.         {
  27.             if(j==1)
  28.                 printf("Probability of covering %d tile  = %.4lf%%\n",j,area[j]/area[0]*100);
  29.             else
  30.                 printf("Probability of covering %d tiles = %.4lf%%\n",j,area[j]/area[0]*100);
  31.         }
  32.         printf("\n");
  33.     }
  34.     return 0;
  35. }
 楼主| l63t89 发表于 2021-1-28 23:14 | 显示全部楼层
遇到问题
此题属于高中的数学题,基本忘得差不多了。
 楼主| l63t89 发表于 2021-1-28 23:14 | 显示全部楼层
I题 498-bis 929476012d4db982e5.png
 楼主| l63t89 发表于 2021-1-28 23:15 | 显示全部楼层
思考过程
不会做。
 楼主| l63t89 发表于 2021-1-28 23:16 | 显示全部楼层
源代码
  1. #include<cstdio>
  2. #include<cmath>
  3. using namespace std;
  4. int main() {
  5. int x, a;
  6. char c;
  7. while(~scanf("%d", &x)) {
  8. int sum = 0;
  9. int ans = 0;
  10. while(~scanf("%d", &a)) {
  11. ans = ans * x + sum;
  12. sum = sum * x + a;
  13. scanf("%c", &c);
  14. if(c == '\n') break;
  15. }
  16. printf("%d\n", ans);
  17. }
  18. return 0;
  19. }
 楼主| l63t89 发表于 2021-1-28 23:16 | 显示全部楼层
遇到问题
不会做(⊙﹏⊙)。
 楼主| l63t89 发表于 2021-1-28 23:17 | 显示全部楼层
收获:
1.C++到C的流畅转换
2.欧几里得算法及扩展
3.对高中知识进行了一定的回忆
4.知道了还有差分序列这个东西
单片小菜 发表于 2021-2-4 12:04 | 显示全部楼层
感觉很高深的样子,没有看明白。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 在线客服 返回列表 返回顶部