日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【CodeForces - 312C】The Closest Pair (思维)

發(fā)布時(shí)間:2023/12/10 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【CodeForces - 312C】The Closest Pair (思维) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

題干:

Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.

The problem is the follows. Given?n?points in the plane, find a pair of points between which the distance is minimized. Distance between?(x1,?y1)?and?(x2,?y2)?is?.

The pseudo code of the unexpected code is as follows:

input n for i from 1 to ninput the i-th point's coordinates into p[i] sort array p[] by increasing of x coordinate first and increasing of y coordinate second d=INF //here INF is a number big enough tot=0 for i from 1 to nfor j from (i+1) to n++totif (p[j].x-p[i].x>=d) then break //notice that "break" is only to be//out of the loop "for j"d=min(d,distance(p[i],p[j])) output d

Here,?tot?can be regarded as the running time of the code. Due to the fact that a computer can only run a limited number of operations per second,?tot?should not be more than?k?in order not to get Time Limit Exceeded.

You are a great hacker. Would you please help Tiny generate a test data and let the code get Time Limit Exceeded?

Input

A single line which contains two space-separated integers?n?and?k?(2?≤?n?≤?2000,?1?≤?k?≤?109).

Output

If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print?n?lines, and the?i-th line contains two integers?xi,?yi?(|xi|,?|yi|?≤?109)?representing the coordinates of the?i-th point.

The conditions below must be held:

  • All the points must be distinct.
  • |xi|,?|yi|?≤?109.
  • After running the given code, the value of?tot?should be larger than?k.

Examples

Input

4 3

Output

0 0 0 1 1 0 1 1

Input

2 100

Output

no solution

題目大意:

給你一個(gè)程序,要求讓你出一組數(shù)據(jù),使得這組數(shù)據(jù)會(huì)讓程序的tot超過k。換句話說,給出一個(gè)最大循環(huán)次數(shù)k,并且已知如果tot超過k就會(huì)TLE。問:能不能給出個(gè)樣例,讓這代碼TLE。

解題報(bào)告:

? 先找到無論如何都不會(huì)讓他TLE的情況,,也就是tot很小,而我們想讓他TLE,,但是死活TLE不了,也就是我們想讓tot盡量大,但是最大情況也是TLE不了的。。。也就是一個(gè)break也沒有執(zhí)行,那么肯定是tot最大的。。。所以我們就是構(gòu)造一組解,讓他一個(gè)break也執(zhí)行不了,就最會(huì)讓他TLE。就行了。

AC代碼:

#include<cstdio> #include<iostream> #include<algorithm> #include<queue> #include<map> #include<vector> #include<set> #include<string> #include<cmath> #include<cstring> #define ll long long #define pb push_back #define pm make_pair #define fi first #define se second using namespace std; const int MAX = 2e5 + 5; ll n,k; int main() {cin>>n>>k;if(n * (n-1) / 2 > k) {for(int i = 1; i<=n; i++) {printf("1 %d\n",i);}}else puts("no solution");return 0 ;}

?

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)

總結(jié)

以上是生活随笔為你收集整理的【CodeForces - 312C】The Closest Pair (思维)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。