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

歡迎訪問(wèn) 生活随笔!

生活随笔

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

编程问答

Mr. Bender and Square

發(fā)布時(shí)間:2024/8/23 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Mr. Bender and Square 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Description

Mr. Bender has a digital table of size?n?×?n, each cell can be switched on or off. He wants the field to have at least?c?switched on squares. When this condition is fulfilled, Mr Bender will be happy.

We'll consider the table rows numbered from top to bottom from 1 to?n, and the columns — numbered from left to right from 1 to?n. Initially there is exactly one switched on cell with coordinates?(x,?y)?(x?is the row number,?y?is the column number), and all other cells are switched off. Then each second we switch on the cells that are off but have the side-adjacent cells that are on.

For a cell with coordinates?(x,?y)?the side-adjacent cells are cells with coordinates?(x?-?1,?y),?(x?+?1,?y),?(x,?y?-?1),?(x,?y?+?1).

In how many seconds will Mr. Bender get happy?

Input

The first line contains four space-separated integers?n,?x,?y,?c(1?≤?n,?c?≤?109;?1?≤?x,?y?≤?n;?c?≤?n2).

Output

In a single line print a single integer — the answer to the problem.

Sample Input

Input 6 4 3 1 Output 0 Input 9 3 8 10 Output 2

Hint

Initially the first test has one painted cell, so the answer is 0. In the second test all events will go as is shown on the figure.?.





//這題就是先算總面積,再減去超出面積,再加上重疊面積。關(guān)鍵要注意細(xì)節(jié)。
#include<iostream>
using namespace std;
int main()
{
? ? ?long long x,n,y,c;
? ? ?cin>>n>>y>>x>>c;
? ? ?long long i,xr,xl,yu,yd,d;
? ? ?x--;y--;
? ? ?long now=0;
? ? ?for(i=1;now<c;i++)
? ? ?{
? ? ? ? ?now=i*i+(i-1)*(i-1);
? ? ? ? ?if(now<c)
? ? ? ? ?continue;
? ? ? ? ?i--;
? ? ? ? ?xr=x+i;
? ? ? ? ?xl=x-i;
? ? ? ? ?yu=y-i;
? ? ? ? ?yd=y+i;
? ? ? ? ?if(xl<0) now-=xl*xl;
? ? ? ? ?if(xr>n-1) now-=(xr-n+1)*(xr-n+1);
? ? ? ? ? if(yu<0)
? ? ? ? ? {
? ? ? ? ? ? ? now-=yu*yu;
? ? ? ? ? ? ? yu++;
? ? ? ? ? ? ? d-=yu;
? ? ? ? ? ? ? if(x+d>n-1)
? ? ? ? ? ? ? ? now+=(x+d-n+2)*(x+d-n+1)/2;
? ? ? ? ? ? ? if(x+yu<0)
? ? ? ? ? ? ? ? now+=(x-d)*(x-d-1)/2;
? ? ? ? ? }
? ? ? ? ? if(yd>n-1)
? ? ? ? ? {
? ? ? ? ? ? ? ?now-=(yd-n+1)*(yd-n+1);
? ? ? ? ? ? ? ?d=yd-n+1;
? ? ? ? ? ? ? ?d--;
? ? ? ? ? ? ? ?if(x+d>n-1) now+=(x+d-n+2)*(x+d-n+1)/2;
? ? ? ? ? ? ? ?if(x-d<0) now+=(x-d)*(x-d-1)/2;
? ? ? ? ? }
? ? ? ? ? i++;
? ? ?}
? ? ?cout<<i-2<<endl;
}

總結(jié)

以上是生活随笔為你收集整理的Mr. Bender and Square的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

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

主站蜘蛛池模板: 天堂中文视频在线 | 成人精品毛片 | 欧美有码视频 | 亚洲第一在线播放 | 日韩精品乱码久久久久久 | 人人搞人人插 | 午夜视频在线观看一区二区 | 草草影院在线免费观看 | 主播一区二区 | 99热这里有精品 | 性福网站 | 69天堂网 | 欧美在线一区视频 | 国产suv精品一区二区 | 国产精品xxx在线 | 亚洲成人av中文字幕 | 久久久成人精品 | 超碰一区二区 | 91久久精品夜夜躁日日躁欧美 | 成人国产精品免费观看视频 | 成人av片免费看 | 九九精品在线观看 | 中国老熟女重囗味hdxx | 亚洲美女偷拍 | 手机看片福利一区 | 极品美妇后花庭翘臀娇吟小说 | 久久久久久久久久久福利 | 午夜婷婷色 | 91精品福利在线 | 婷婷五月小说 | 熟妇人妻中文字幕无码老熟妇 | 少妇人妻一级a毛片 | 福利片第一页 | 亚洲伊人天堂 | 久久无码人妻丰满熟妇区毛片 | 天堂网在线最新版www中文网 | 久久99精品久久只有精品 | 樱桃香蕉视频 | 欧美亚洲自拍偷拍 | a级在线观看视频 | 国产精品自在线 | 亚洲视频一区二区三区四区 | 欧美黄色特级片 | 中文字幕欧美一区 | 伊人久操| 涩涩视频网址 | 国产凹凸一区二二区 | 国产乱码精品一区二三赶尸艳谈 | 日韩中文字幕久久 | 久青草资源福利视频 | 日韩三级在线播放 | 香港台湾日本三级大全 | 亚洲AV无码国产精品播放在线 | www.欧美激情| 超碰在线免费看 | 欧美日韩性生活视频 | 国产成人精品午夜福利Av免费 | 性色AV无码久久一区二区三 | 国产精品成人在线观看 | 制服丝袜在线视频 | 操韩国美女 | 色免费看 | 久久综合丁香 | 国产美女网站视频 | 落日余晖图片 | 男人av的天堂 | 男女啊啊啊视频 | 国产在线第二页 | 中文字幕在线欧美 | 日韩欧美亚洲综合 | 久久在线免费 | 国产视频91在线 | 自拍偷拍亚洲区 | 日韩网站免费观看 | 麻豆福利在线 | 国内av片 | 久久99精品久久久久久水蜜桃 | 在线观看免费福利 | av瑟瑟 | 91精品国产乱码久久久 | 国产视频污在线观看 | 91看片免费看 | 超碰超碰超碰超碰 | 日本www黄 | 日韩一区二区三区四区在线 | 蜜臀久久99精品久久久 | 美女视频久久久 | 9999热视频| 奇米视频在线观看 | 国产精品99999 | 91sao| 性欧美熟妇videofreesex | 成人免费视屏 | 熟女熟妇伦久久影院毛片一区二区 | 欧美国产日韩一区二区 | 成人毛片视频网站 | 久热中文字幕在线 | 91视频最新地址 | 午夜天堂在线 |