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 }

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

posted on 2013-05-30 00:05  aries__liu  阅读(212)  评论(0编辑  收藏  举报