码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • Oj错题。。


     

    1. #include
    2. #define fst first
    3. #define scd second
    4. #define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
    5. #define endl '\n'
    6. #define mems(a,x) memset(a,x,sizeof(a))
    7. #define pii pair
    8. using namespace std;
    9. using ll = long long;
    10. using ull = unsigned long long;
    11. using ldb = long double;
    12. using db = double;
    13. void solve();
    14. int main(){
    15. //IOS;
    16. solve();
    17. }
    18. void solve(){
    19. int n;
    20. cin >> n;
    21. vector> a(n);
    22. map<double,int> mp;
    23. for( int i = 0; i < n; ++i){
    24. cin >> a[i][0] >> a[i][1];
    25. a[i][2] = i;
    26. }
    27. ldb maxx = -1, maxi = -1;
    28. ldb maxi1 = -1;
    29. vector<bool> f(n,false);
    30. for( int i = 0; i < n; ++i){
    31. for(int j = i + 1; j < n; ++j){
    32. ldb k = (a[j][1] - a[i][1])*1.0 / (a[j][0] - a[i][0]);
    33. mp[k] ++;
    34. if(maxx < mp[k]){
    35. maxi1 = maxi;
    36. maxx = mp[k];
    37. maxi = k;
    38. }
    39. }
    40. }
    41. // maxx = n * n - 1 / 2
    42. ll ans = 0,ans1 = 0;
    43. ldb k;
    44. //这里犯了一个大错误,只考虑到斜率相等,就认为他们在一条直线上面了。
    45. for ( int i = 0; i < n; ++i){
    46. for( int j = i + 1; j < n; ++j){
    47. k = (a[j][1] - a[i][1])*1.0 / (a[j][0] - a[i][0]);
    48. if(k == maxi){
    49. if(f[i] == 0 && f[j] == 0){
    50. ans += 2;
    51. f[i] = f[j] = true;
    52. }
    53. else if ( a[i][2] == 0){
    54. f[i] = true;
    55. ++ans;
    56. }
    57. else if( a[j][2] == 0){
    58. f[j] = true;
    59. ++ ans;
    60. }
    61. else
    62. continue;
    63. }
    64. if(k == maxi1){
    65. if(f[i] == 0 && f[j] == 0){
    66. ans1 += 2;
    67. f[i] = f[j] = true;
    68. }
    69. else if ( a[i][2] == 0){
    70. f[i] = true;
    71. ++ans1;
    72. }
    73. else if( a[j][2] == 0){
    74. f[j] = true;
    75. ++ ans1;
    76. }
    77. else
    78. continue;
    79. }
    80. }
    81. }
    82. cout << max(ans,ans1) << endl;
    83. }

  • 相关阅读:
    OpenStack-train版安装之环境准备
    【设计模式】Java设计模式 - 享元模式
    Hadoop3:HDFS-查看logs文件,排查NameNode故障原因。
    【React】精选5题
    CIO们开始将软件供应链升级为安全优先级top
    基于PHP+MySQL大学教学工作网络平台的设计与实现
    Java RMI详解
    SpringBoot - @ControllerAdvice注解详解
    pytorch环境安装和配置
    Unity射线实现碰撞检测(不需要rigbody组件)
  • 原文地址:https://blog.csdn.net/2303_79552392/article/details/139482460
  • 最新文章
  • 沪漂五周年了:我越来越迷茫了
    Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
    MySQL-Seconds_behind_master的精度误差
    [MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
    AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
    Agent OS :五种驯服不确定性的范式
    PortSwigger SQL注入LAB11
    数据库即时编译JIT
    [Begin]AI Learn Data Day 0
    深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号