国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

P2685抓牛(bfs)

2019-11-11 07:26:45
字體:
供稿:網(wǎng)友

題見洛谷

#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<string>#include<cmath>#include<vector>#define LL long long#define p 0.00000001using namespace std;int n,k;int pos[10000009];int tim[10000009];bool f[10000009];int bfs(){ int head=0,tail=1; pos[1]=n; while(head<tail){ head++; for(int i=1;i<=3;i++){ int x; if(i==1) x=pos[head]+1; if(i==2) x=pos[head]-1; if(i==3) x=pos[head]*2; if(x>=0&&x<=100000&&!f[x]){ pos[++tail]=x; f[x]=true; tim[pos[tail]]=tim[pos[head]]+1; if(pos[tail]==k) return tim[k]; } } }}int main(){ //memset(f,false,sizeof(f)); scanf("%d%d",&n,&k); if(n>=k){
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 娄底市| 嘉兴市| 德清县| 容城县| 桑日县| 万荣县| 梁河县| 昭通市| 江永县| 德阳市| 十堰市| 本溪市| 宜州市| 寻乌县| 任丘市| 华坪县| 乌恰县| 巢湖市| 东莞市| 广灵县| 容城县| 囊谦县| 清徐县| 读书| 鄯善县| 苏尼特右旗| 康乐县| 海南省| 黑水县| 井冈山市| 平阳县| 无极县| 东安县| 子洲县| 武城县| 柏乡县| 离岛区| 买车| 青海省| 东兰县| 张家港市|