zoukankan      html  css  js  c++  java
  • Codeforces Round #185 (Div. 1) A. The Closest Pair

    题目链接:http://codeforces.com/problemset/problem/311/A

    题目大意:

      题目很短,不解释了。^_^

    题目思路:

      开始感觉很难,没思路。看了解题报告,发现原来是道水题嘛。程序里面有个break语句,要让循环次数达到最大,并且循环次数容易计算,只需要让这个break;永远不会执行就可以了。也就是说,可以让p[j].x - p[i].x >= d 永远不成立,只需要让p[j].x - p[i].x总等于0就可以了!因为题目让生成任意一组符合条件的数据嘛,所以,可以让产生的所有的点的横坐标都是一样的就可以了。

     1 #include <cstdio>
     2 #include <cstdlib>
     3 #include <cstring>
     4 #include <iostream>
     5 #include <cmath>
     6 using namespace std;
     7 #define LL long long 
     8 int main(void) {
     9 #ifndef ONLINE_JUDGE
    10   //freopen("185_c.in1", "r", stdin);
    11 #endif
    12   LL n, k; scanf("%I64d%I64d", &n, &k);
    13   if (n*(n-1)/2 <= k){
    14     printf("no solution\n");
    15   }
    16   else {
    17     for (int i = 0; i < n; ++i) {
    18        printf("1 %d\n", i);
    19     }
    20   }
    21   return 0;
    22 }

    很简单的思路,当初为什么没有想到?

  • 相关阅读:
    indexDB的用法
    append动态生成的元素,无法触发事件的原因及解决方案
    jquery中attr()和prop()的区别
    arguments.callee
    meter标签度量衡如何改变颜色
    Nginx入门
    linux中的权限管理
    python_面向对象
    ORM
    Flask入门
  • 原文地址:https://www.cnblogs.com/liuxueyang/p/3107300.html
Copyright © 2011-2022 走看看