White Water Rafting

White Water Rafting

这里写图片描述

题意:给出两个多边形(二维坐标),保证第一个在第二个的内部,这样两个多边形就可以组成一个环,求一个圆,能在该环内饶一周,且要求该圆的半径尽量大,输出这个半径值。

解法:明显就是求内多边形顶点到外多边形边的距离以及外多边形顶点到内多边形边的距离的最小值,即点到直线的距离

#include <iostream>
using namespace std;
#include <stdio.h>
#include <math.h>

double a[200][3], b[200][3], ans;
int n, m;

double sqr(double x) {
    return x*x;
}

void count(double x1, double y1, double x2, double y2, double x, double y) {
    double a1, b1, c1;
    if (fabs(x1-x2) < 1e-6) {
        a1 = 1; b1 = 0;
        c1 = -x1;
    } else {
        a1 = (y2-y1)/(x2-x1);
        b1 = -1;
        c1 = y1-a1*x1;;
    }
    double len = sqrt(sqr(x1-x2)+sqr(y1-y2));

    double dis = fabs(a1*x+b1*y+c1)/sqrt(a1*a1+b1*b1);  
    if (dis*dis+len*len < sqr(x1-x)+sqr(y1-y)) {
        dis = sqrt(sqr(x2-x)+sqr(y2-y));
    } else if (dis*dis+len*len < sqr(x2-x)+sqr(y2-y)) {
        dis = sqrt(sqr(x1-x)+sqr(y1-y));
    }               
    if (dis < ans) ans = dis;
}

int main() {
    int tt;
    cin >> tt;
    for (int cases = 1; cases <= tt; cases++) {
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> a[i][1] >> a[i][2];
        a[0][1] = a[n][1];
        a[0][2] = a[n][2];
        cin >> m;
        for (int i = 1; i <= m; i++)
            cin >> b[i][1] >> b[i][2];
        b[0][1] = b[m][1];
        b[0][2] = b[m][2];

        ans = 1e9;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                count(a[i-1][1], a[i-1][2], a[i][1], a[i][2], b[j][1], b[j][2]);
            }
        }
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                count(b[i-1][1], b[i-1][2], b[i][1], b[i][2], a[j][1], a[j][2]);
            }
        }
        ans = ans/2;
        printf("%.10lf\n", ans);
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
UCF101是一个动作识别数据集,包含101个不同的动作类别。每个类别有不同数量的样本,具体数目如下: 1. ApplyEyeMakeup: 145 2. ApplyLipstick: 114 3. Archery: 145 4. BabyCrawling: 132 5. BalanceBeam: 134 6. BandMarching: 167 7. BaseballPitch: 150 8. Basketball: 134 9. BasketballDunk: 137 10. BenchPress: 148 11. Biking: 150 12. Billiards: 145 13. BlowDryHair: 123 14. BlowingCandles: 100 15. BodyWeightSquats: 175 16. Bowling: 146 17. BoxJump: 131 18. BoxingPunchingBag: 147 19. BoxingSpeedBag: 148 20. BreastStroke: 148 21. BrushingTeeth: 146 22. CleanAndJerk: 151 23. CliffDiving: 141 24. CricketBowling: 145 25. CricketShot: 150 26. CuttingInKitchen: 150 27. Diving: 147 28. Drumming: 166 29. Fencing: 145 30. FieldHockeyPenalty: 156 31. FloorGymnastics: 173 32. FrisbeeCatch: 143 33. FrontCrawl: 156 34. GolfSwing: 166 35. Haircut: 139 36. HammerThrow: 139 37. HandstandPushups: 137 38. HandstandWalking: 166 39. HeadMassage: 144 40. HighJump: 145 41. HorseRace: 155 42. HorseRiding: 150 43. HulaHoop: 140 44. IceDancing: 147 45. JavelinThrow: 148 46. JugglingBalls: 166 47. JumpingJack: 151 48. JumpRope: 154 49. Kayaking: 116 50. Knitting: 100 51. LongJump: 140 52. Lunges: 146 53. MilitaryParade: 138 54. Mixing: 147 55. MoppingFloor: 151 56. Nunchucks: 118 57. ParallelBars: 149 58. PizzaTossing: 100 59. PlayingCello: 150 60. PlayingDaf: 100 61. PlayingDhol: 100 62. PlayingFlute: 149 63. PlayingGuitar: 147 64. PlayingPiano: 150 65. PlayingSitar: 100 66. PlayingTabla: 100 67. PlayingViolin: 148 68. PoleVault: 145 69. PommelHorse: 145 70. PullUps: 150 71. Punch: 150 72. PushUps: 150 73. Rafting: 100 74. RockClimbingIndoor: 155 75. RopeClimbing: 141 76. Rowing: 150 77. SalsaSpin: 150 78. ShavingBeard: 144 79. Shotput: 146 80. SkateBoarding: 144 81. Skiing: 146 82. Skijet: 100 83. SkyDiving: 144 84. SoccerJuggling: 133 85. SoccerPenalty: 152 86. StillRings: 145 87. SumoWrestling: 145 88. Surfing: 147 89. Swing: 150 90. TableTennisShot: 145 91. TaiChi: 106 92. TennisSwing: 145 93. ThrowDiscus: 145 94. TrampolineJumping: 145 95. Typing: 144 96. UnevenBars: 144 97. VolleyballSpiking: 149 98. WalkingWithDog: 152 99. WallPushups: 145 100. WeightedSquat: 147 101. Windsurfing: 143
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值