题目链接:https://vjudge.net/problem/HDU-6814

题意:在[1,n]中随机取三个数a,b,c作为直角四面体的三条直角棱,求顶点d到ABC面的高的倒数平方的数学期望。

思路:

  1. 1 //#include<bits/stdc++.h>
  2. 2 #include<time.h>
  3. 3 #include <set>
  4. 4 #include <map>
  5. 5 #include <stack>
  6. 6 #include <cmath>
  7. 7 #include <queue>
  8. 8 #include <cstdio>
  9. 9 #include <string>
  10. 10 #include <vector>
  11. 11 #include <cstring>
  12. 12 #include <utility>
  13. 13 #include <cstring>
  14. 14 #include <iostream>
  15. 15 #include <algorithm>
  16. 16 #include <list>
  17. 17 using namespace std;
  18. 18 #define eps 1e-10
  19. 19 #define PI acos(-1.0)
  20. 20 #define lowbit(x) ((x)&(-x))
  21. 21 #define zero(x) (((x)>0?(x):-(x))<eps)
  22. 22 #define mem(s,n) memset(s,n,sizeof s);
  23. 23 #define ios {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
  24. 24 typedef long long ll;
  25. 25 typedef unsigned long long ull;
  26. 26 const int maxn=6e6+5;
  27. 27 const int Inf=0x7f7f7f7f;
  28. 28 const ll Mod=1e9+7;
  29. 29 const int N=3e3+5;
  30. 30 bool isPowerOfTwo(int n) { return n > 0 && (n & (n - 1)) == 0; }//判断一个数是不是 2 的正整数次幂
  31. 31 int modPowerOfTwo(int x, int mod) { return x & (mod - 1); }//对 2 的非负整数次幂取模
  32. 32 int getBit(int a, int b) { return (a >> b) & 1; }// 获取 a 的第 b 位,最低位编号为 0
  33. 33 int Max(int a, int b) { return b & ((a - b) >> 31) | a & (~(a - b) >> 31); }// 如果 a>=b,(a-b)>>31 为 0,否则为 -1
  34. 34 int Min(int a, int b) { return a & ((a - b) >> 31) | b & (~(a - b) >> 31); }
  35. 35 ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
  36. 36 ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
  37. 37 int Abs(int n) {
  38. 38 return (n ^ (n >> 31)) - (n >> 31);
  39. 39 /* n>>31 取得 n 的符号,若 n 为正数,n>>31 等于 0,若 n 为负数,n>>31 等于 -1
  40. 40 若 n 为正数 n^0=n, 数不变,若 n 为负数有 n^(-1)
  41. 41 需要计算 n 和 -1 的补码,然后进行异或运算,
  42. 42 结果 n 变号并且为 n 的绝对值减 1,再减去 -1 就是绝对值 */
  43. 43 }
  44. 44 ll binpow(ll a, ll b,ll c) {
  45. 45 ll res = 1;
  46. 46 while (b > 0) {
  47. 47 if (b & 1) res = res * a%c;
  48. 48 a = a * a%c;
  49. 49 b >>= 1;
  50. 50 }
  51. 51 return res%c;
  52. 52 }
  53. 53 void extend_gcd(ll a,ll b,ll &x,ll &y)
  54. 54 {
  55. 55 if(b==0) {
  56. 56 x=1,y=0;
  57. 57 return;
  58. 58 }
  59. 59 extend_gcd(b,a%b,x,y);
  60. 60 ll tmp=x;
  61. 61 x=y;
  62. 62 y=tmp-(a/b)*y;
  63. 63 }
  64. 64 ll mod_inverse(ll a,ll m)
  65. 65 {
  66. 66 ll x,y;
  67. 67 extend_gcd(a,m,x,y);
  68. 68 return (m+x%m)%m;
  69. 69 }
  70. 70 ll eulor(ll x)
  71. 71 {
  72. 72 ll cnt=x;
  73. 73 ll ma=sqrt(x);
  74. 74 for(int i=2;i<=ma;i++)
  75. 75 {
  76. 76 if(x%i==0) cnt=cnt/i*(i-1);
  77. 77 while(x%i==0) x/=i;
  78. 78 }
  79. 79 if(x>1) cnt=cnt/x*(x-1);
  80. 80 return cnt;
  81. 81 }
  82. 82 int mod=998244353;
  83. 83 ll a[maxn],b[maxn];
  84. 84 void f()
  85. 85 {
  86. 86 a[1]=1;
  87. 87 b[1]=1;
  88. 88 for(int i=2;i<maxn;i++)
  89. 89 {
  90. 90 a[i]=(mod-mod/i)*a[mod%i]%mod;
  91. 91 b[i]=(b[i-1]+a[i]*a[i]%mod)%mod;
  92. 92 }
  93. 93 }
  94. 94 int main()
  95. 95 {
  96. 96 int t;
  97. 97 f();
  98. 98 scanf("%d",&t);
  99. 99 while(t--)
  100. 100 {
  101. 101 int n;
  102. 102 scanf("%d",&n);
  103. 103 printf("%lld\n",3*a[n]*b[n]%mod);
  104. 104 }
  105. 105 return 0;
  106. 106 }

I - Tetrahedron HDU - 6814的更多相关文章

  1. hdu 6814 Tetrahedron 规律+排列组合逆元

    题意: 给你一个n,你需要从1到n(闭区间)中选出来三个数a,b,c(可以a=b=c),用它们构成一个直角四面体的三条棱(可看图),问你从D点到下面的三角形做一条垂线h,问你1/h2的期望 题解: 那 ...

  2. HDU 5839 Special Tetrahedron (计算几何)

    Special Tetrahedron 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...

  3. HDU 5839 Special Tetrahedron

    HDU 5839 Special Tetrahedron 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n ...

  4. HDU 5839 Special Tetrahedron 计算几何

    Special Tetrahedron 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...

  5. hdu 5726 tetrahedron 立体几何

    tetrahedron/center> 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5726 Description Given four p ...

  6. HDU #5733 tetrahedron

    tetrahedron 传送门 Time Limit: 2000/1000 MS (Java/Others)   Memory Limit: 65536/65536 K (Java/Others) P ...

  7. HDU 5839 Special Tetrahedron (2016CCPC网络赛08) (暴力+剪枝)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5839 在一个三维坐标,给你n个点,问你有多少个四面体(4个点,6条边) 且满足至少四边相等 其余两边不 ...

  8. HDU 5733 tetrahedron(计算几何)

    题目链接 tetrahedron 题目大意 输入一个四面体求其内心,若不存在内心则输出"O O O O" 解题思路 其实这道题思路很简单,只要类推一下三角形内心公式就可以了. 至于 ...

  9. hdu 5733 tetrahedron 四面体内切球球心公式

    tetrahedron Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

随机推荐

  1. Spring-cloud-netflix-hystrix

    服务注册中心eureka-server已经搭好,并且SPRING-CLOUD-NETFLIX-EUREKA-CLIENT-APPLICATION提供一个hello服务 畏怯还编写一个eureka-cl ...

  2. Chrome DevTools & performance & keywords

    Chrome DevTools & performance & keywords performance / 优化性能 https://developers.google.com/we ...

  3. npm publish bug & solution

    npm publish bug & solution npm ERR! Unexpected token < in JSON at position 0 while parsing ne ...

  4. 2016 最新的 树莓派3 Raspberry Pi 3 上手评测 图解教程 新手必看!(VNC 安装,启动,关闭)

    1.png . 官方教程: INSTALLING OPERATING SYSTEM IMAGES: https://www.raspberrypi.org/documentation/installa ...

  5. Android四大组件简介:Android 基础知识,开发教程

    Android 四大组件: Activity.Service.Broadcast Receiver.Content Provider. http://developer.android.com/int ...

  6. holy shit StackOverflow

    holy shit StackOverflow refs https://stackoverflow.com/users/5934465/xgqfrms?tab=questions xgqfrms 2 ...

  7. js group objects in an array

    js group objects in an array js group objects in an array var groupBy = function(xs, key) { return x ...

  8. TypeScript Generics

    TypeScript Generics https://www.typescriptlang.org/docs/handbook/generics.html 泛型 1 Generic Interfac ...

  9. js滚轮事件兼容写法

    /** * 简易的事件添加方法 */ define(function(require, exports, module) { exports.addEvent = (function(window, ...

  10. NGK Global首尔站:内存是未来获取数字财富的新模式

    近日,NGK路演在NGK韩国社区的积极举办下顺利落下帷幕.此次路演在首尔举行,在活动当天,NGK的核心团队成员.行业专家.投资银行精英.生态产业代表和数百名NGK韩国社区粉丝一起参加NGK Globa ...