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 }

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

  • 相关阅读:
    poj 2312 Battle City
    poj 2002 Squares
    poj 3641 Pseudoprime numbers
    poj 3580 SuperMemo
    poj 3281 Dining
    poj 3259 Wormholes
    poj 3080 Blue Jeans
    poj 3070 Fibonacci
    poj 2887 Big String
    poj 2631 Roads in the North
  • 原文地址:https://www.cnblogs.com/liuxueyang/p/3107300.html
Copyright © 2011-2022 走看看