ibm 3278

Discover ibm 3278, include the articles, news, trends, analysis and practical advice about ibm 3278 on alibabacloud.com

(Guang Search) Catch that Cow--poj--3278

Link:http://poj.org/problem?id=3278 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 62113 Accepted: 19441 DescriptionFarmer John had been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point n (0≤ N ≤100,000) on a number line and the cow are at a point K (0≤ K ≤100,000) on the same number line. Farmer John has modes of transportat

Poj 3278 catch that cow (BFS search)

question. The question was directly made using brute force and I had been wondering if it would be enough for Division 2, then at the beginning I also want to use violence to do, but some of the later do not take into account, this question is also more than the copy of the http://blog.csdn.net/whjkm/article/details/26985421 of the problem (once that the link ), later, I carefully read the question. There is a big difference between the question and the question. The simple question is that it

Poj 3278 Catch That Cow (broad search), poj3278

Poj 3278 Catch That Cow (broad search), poj3278 Catch That Cow Time Limit:2000 MS Memory Limit:65536 K Total Submissions:45087 Accepted:14116 DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a pointN(0 ≤N≤ 100,000) on a number line and the cow is at a pointK(0 ≤K≤ 100,000) on t

Poj 3278 catch that cow

search question. At the beginning, I thought it was necessary to find a Unified Algorithm formula to calculate the minimum number of steps from "Start number" to "end number, however, after thinking about it for half a day, I finally thought about solving the problem with violence. But isn't this an algorithm question for BFS? Yes, it is not a common Linear brute force search, but the BFS concept is needed. After careful analysis, you can know that computer programs cannot dynamically decide ho

POJ 3278 Catch that Cow

=Q.front (); at Q.pop (); - if(q2 = = b) {//the output went a few steps after I found it. -printf"%d\n", STEP[Q2]); - return ; - } - //John, go--1 only if he has a positive coordinate at this point . in intx = Q2-1; - if(!maps[x] Q2 >0) { toMAPS[X] =true; +Q1 =x; -STEP[Q1] = step[q2] +1; the Q.push (Q1); * } $ //as John walked backwards only-1 so only Q2 Panax Notoginseng if(Q2 b) { -x = q2 +1; the if(!Maps[x])

POJ 3278 Catch that Cow BFS

Title Link: http://poj.org/problem?id=3278Test instructions: one-dimensional space. Initial coordinate n. Goal K. Move the way n-1,n+1,2*n, and then want to know the minimum number of steps to the end,Idea: The BFS can no longer water. At first I don't want to knock. Knock on the happy re. Then know the existence of "pruning". is to optimize it. If the current location is now>k. That's the only way now-1 can go. Well. If you do not prune, re data such as 0 100000.The focus is on pruning.The AC c

Poj 3278 catch that cow BFS

Source: http://poj.org/problem? Id = 3278 Question: How many steps are required from the start point to the end point for a start point and an end point. You can take one step to the left, one step to the right, or the coordinate is multiplied by 2. Idea: a raw BFs, a water question. Code: # include # include # include # include using namespace STD; # define CLR (ARR, Val) memset (ARR, Val, sizeof

POJ 3278 Catch that Cow---simple BFS

/*POJ 3278 Catch that Cow---simple BFS*/#include#include#includeusing namespacestd;Const intMAXN =100005;BOOLVISIT[MAXN];intSTEP[MAXN];intBFsintNintk) { if(n = =k)return 0; memset (Visit,0,sizeofvisit); Queueint> q;//on the node where the store is visited but the next point is to be judgedQ.push (n); Step[n]=0; Visit[n]=1; intX,next; while(!Q.empty ()) {x=Q.front (); Q.pop (); for(inti =0; I 3; ++i) { //i = 0,1,2 means wide search in d

Poj 3278 catch that cow

Catch that cowtime limit: 2000 msmemory limit: 65536 kbthis problem will be judged on PKU. Original ID: 3278 64-bit integer Io format: % LLD Java class name: Main Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a pointN(0 ≤N≤ 100,000) on a number line and the cow is at a pointK(0 ≤K≤ 100,000) on the same number line. Farmer John has two modes of transportation: Walking and teleporting. *

POJ 3278 Catch That Cow

POJ 3278 Catch That CowC-Catch That Cow Crawling in process...Crawling failedTime Limit:2000 MSMemory Limit:65536KB64bit IO Format:% I64d % I64uSubmitStatus Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a pointN(0 ≤N≤ 100,000) on a number line and the cow is at a pointK(0 ≤K≤ 100,000) on the same number line. Farmer John has two modes of transportation: walking and telep

POJ 3278 Catch that Cow wide search

]=step[a]+1;//The current number of steps equals the last step of +1;vis[flag]=1;//marked as 1;Q.push (flag);//queue; if(flag==n)//If the current value is n; returnStep[flag];//Returns the number of steps;} } }return 0;//If you are submitting C + +, do not return a value; //But if it is g++, a return 0 must be required; //This is a compiler problem, the specific is not very clear;}intMain () {intN,k;//k Chase N; while(~scanf("%d%d", k,n))//He

POJ 3278 Catch that Cow

Problem-Solving ideas: Simple wide search, the key is pruning.1#include 2#include 3#include 4#include 5 using namespacestd;6 Const intMAXN =100005;7 intVIS[MAXN];//Mark whether this point has passed8 intN, K;9 Ten One structnode{ A intx, CNT; - }p, now; - theQueueQ; - - intBFsintXintCNT) - { +memset (Vis,0,sizeof(VIS));//initialized to never go through - while(!q.empty ()) Q.pop (); +p.x = x, p.cnt =CNT; A Q.push (p); at - while(!q.empty ()) - { -p =Q.front (); - Q.pop ();

POJ 3278 BFS

Link: poke hereCatch that CowTime limit:2000ms Memory limit:65536kDescriptionFarmer John had been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0≤n≤100,000) on a number line and the cow are at a point K (0≤k≤100,000) on the same number Line. Farmer John has modes of transportation:walking and teleporting.* WALKING:FJ can move from any point x to the points X-1 or X + 1 inch a single minute* TELEPORTING:FJ can move from any point X to the p

POJ 3278 Catch that Cow

200,000 AC. However, the running time is more than 2000 MS, it feels Java is really much slower than C + +.Java AC CodeImportjava.util.LinkedList;ImportJava.util.Queue;ImportJava.util.Scanner; Public classMain {StaticqueueNewLinkedlist(); Static intmax = 200010; Static BooleanMarked[] =New Boolean[Max]; Static intSteps[] =New int[Max]; Static intBoy , Cow; Public Static voidMain (string[] args) {Scanner sc=NewScanner (system.in); Boy=Sc.nextint (); Cow=Sc.nextint (); BFS (); System.o

POJ 3278 catch that cow BFS (base water)

] [Discuss]Home Page Go back to top#include #includestring.h>#include#include#includeusing namespacestd;vis[200005];structnode{intx; intDis;}; Node u,v;intBFsintStartintend) {u.x=start; U.dis=0; QueueQ; Vis[start]=true; Q.push (U); while(!Q.empty ()) {u=Q.front (); Q.pop (); if(u.x==end)returnU.dis; for(intI=0;i3; i++){ if(i==0) v.x=u.x+1; Else if(i==1) v.x=u.x-1; Else if(i==2) v.x=u.x*2; if(!vis[v.x]v.x>=0v.x100001) {vis[v.x]=true; V.dis=u.dis+1; Q.push (v); }

POJ 3278 Catch that Cow (BFS)

Topic Link: Catch that CowResolution: two numbers n and K, three operations: + 1,-1, * *, q, n at least how many times the operation can be equal to K.The simplest BFS template has, noteCondition of +1: x+1 -1 conditions: x-1 >= 0Conditions: x AC Code:#include Copyright NOTICE: This article is sxk original article, reprint please attach this article link ^_^ POJ 3278 Catch that Cow (BFS)

POJ 3278 Catch that Cow

the minimum amount of time is how much (also can be said to be the smallest number of steps)! Note that walking can move around, but teleport (that is, another way to move forward only), and then you use these three ways to the one-dimensional coordinates of the points in a wide search, the minimum number of steps to reach the end!The problem is different from the previous one is that the previous is in the two-dimensional plane on the wide search (there are different paths), find the shortest

Bfs/poj 3278 Catch that Cow

1#include 2#include 3#include 4 using namespacestd;5 Const intmaxn=200010;6 intn,k;7 BOOLV[MAXN];8 struct Point9 {Ten intx; One intStep; A }; - intBFS () - { thememset (V,0,sizeof(v)); -Queueque; - Point now,next; -now.x=N; +now.step=0; -v[n]=1; + Que.push (now); A at while(!que.empty ()) - { -now=Que.front (); - Que.pop (); - if(now.x==k) Break; - innext.x=now.x+1; - if(next.x>=0 NEXT.XV[next.x]) to { +v[next.x]=1; -next.step=now.step+1; the Que.push (

"Turn" POJ-3278 Catch that Cow:bfs

Can think of a wide search to solve this problem is also enough Diao: wide search to the target node can be answered steps#include #include#includeusing namespacestd;structnode{intValue, Steps; Node (intNints): Value (N), Steps (s) {}};queueQue;intvisited[100000];intMain () {intN, K; Memset (visited,0,sizeof(visited)); CIN>>N>>K; Que.push (Node (N,0)); Visited[n]=1; while( !Que.empty ()) {Node Top=Que.front (); if(Top.value = =K) {coutEndl; Break; } if(top.value-1>=0 visited[top

POJ 3278 Catch that Cow BFS difficulty: 1

http://poj.org/problem?id=3278From N, to both sides of the transfer, in order not to allow unlimited expansion of the number, limited to 2*k within,Attention cannot be limited to k, otherwise there is a lack of continuous use-1 of the results obtained#include    POJ 3278 Catch that Cow BFS difficulty: 1

Total Pages: 15 1 2 3 4 5 .... 15 Go to: Go

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.