The question ： Find the minimum number of steps to reach the boundary ..

At first I thought it was bfs, But the data 10^6 It's too big , Definitely not ...

A question of thinking , Pay attention to the over boundary ...

``` #include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int INF=(<<);
int n,m,x,y,a,b;
int ok(int x1,int y1)
{
if(x1<) x1=-x1;
if(y1<) y1=-y1;
if(x1%a==&&y1%b==)// It's just right Reach the border
{
if((x1/a-y1/b)%==)// And the difference between the two is even ..
{
if(x1/a>y1/b)
return x1/a;
else
return y1/b;
}
}
return INF;
}
int main()
{
int d[];
while(cin>>n>>m>>x>>y>>a>>b)
{
if((x==&&y==m)||(x==n&&y==)||(x==n&&y==m)||(x==&&y==))
{
cout<<""<<endl;
continue;
}
if(a>=n||b>=m)// It's possible to cross the line in one step ..
{
cout<<"Poor Inna and pony!"<<endl;
continue;
}
d[]=ok(x-,y-m);
d[]=ok(x-n,y-);
d[]=ok(x-n,y-m);
d[]=ok(x-,y-);
sort(d,d+);
if(d[]==INF)
cout<<"Poor Inna and pony!"<<endl;
else
cout<<d[]<<endl;
}
return ;
}```

## cf A. Inna and Pink Pony( Thinking questions ) More articles about

1. 220 DIV2 A. Inna and Pink Pony

Inna and Pink Pony Input n,m,i,j,a,b Can be seen as n That's ok m Columns of the matrix , The starting point (i,j), Each move (a,b),(-a,-b),(-a,b),(a,-b) Can be moved to (1,m),(n,1) ...

2. Codeforces 374A - Inna and Pink Pony

Original address :http://codeforces.com/contest/374/problem/A I haven't written the Title Summary for a long time , I've been in very bad shape recently , Whether it's programming or homework or mental outlook ……NOIP After hanging up, I always feel lack of ...

3. codeforces 374A Inna and Pink Pony Problem solving report

Topic link :http://codeforces.com/problemset/problem/374/A The title mean : Give a n That's ok  m Column The chessboard of , To place the coordinate point at (i, j) Of candy Move ...

4. codeforces 499A.Inna and Pink Pony Problem solving report

Topic link :http://codeforces.com/problemset/problem/499/A The title mean : There are two buttons :1. If the current viewing time is t,player Can automatically process the next minute , Let's understand ...

5. ACM Thinking exercises Section A

Title address : The topic is for beginners Codeforce div2/div1 Of C Title and D topic . Answer key : A:CF Thinking connection –CodeForces -214C ( A topological sort + thinking + greedy ) B:CF– Thinking practice -- CodeFo ...

6. zoj 3778 Talented Chef( Thinking questions )

subject The question : One can do it in one minute at the same time m One of the steps of a dish , share n dish , Each dish has its own xi A step , The shortest time to finish . Ideas : A water thinking problem , There's no need to go Consider the simulation process And make that dish first ( That's what I did in the competition ...

7. ZOJ 3829 greedy Thinking questions

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3829 When doing this on the spot , Feeling is a question of thinking . I'm not intelligent enough . I dare not do it , Think about the intelligence of your teammates ...

8. Luogu P4643 [ National Team ] Ali and peach game （ Thinking questions + greedy ）

Thinking questions , Good question Divide the weight of each edge equally to the two vertices of the edge , And then there's a sb Greedy Proof of correctness : If two vertices of an edge are selected by one person , The contribution of a whole side is put together If two candidates are chosen , The difference offsets , It's equivalent to no one ...

9. C. Nice Garland Codeforces Round #535 (Div. 3) Thinking questions

C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

## Random recommendation

1. stay Mac mini Compiled on Android Source code

Reference article 1.Android 6.0 Source code compilation practice 2. compile Android Source code fatal error solution Practice process 1.Mac Lower installation Ubuntu Dual system (1)Ubuntu edition :Ubuntu 15.10 notes : real ...

2. Association rules -R Language implementation

Association rules code{white-space: pre;} pre:not([class]) { background-color: white; }if (window.hljs && ...

Because of this problem ,Google And Baidu , The main solution on the Internet is this code : <script language="JavaScript"> var hkey_root, ...

4. [ turn ]div in table The question of the middle Div And body Top clearance

In this paper, from :http://www.cnblogs.com/jinhui/archive/2008/09/24/1297729.html take div Of text-align Set to center, And then table Of ...

5. php String connection

<?php\$s = "a";\$s .= "b";echo \$s; ?> Output ab String connection : .=

6. UFLDL Tutorial of （ One ）sparseae_exercise

below , take UFLDL In the tutorial sparseae_exercise The functions and notes in the exercise are listed below First , The calling relation of each function is given The main function :train.m (1) call sampleIMAGES Function to extract multiple... From a known image ...

7. Detailed explanation SSH The principles and advantages of the framework

Struts Principles and advantages of .        Struts working principle   MVC namely Model-View-Controller Abbreviation , Is a common design pattern .MVC It weakens the coupling between business logic interface and data interface , And let ...

8. Reading notes - You don't know JS On - Function scope and block scope

Function scope Javascript Has a function based scope , Each function declared , Will produce a corresponding scope . // The global scope contains f1 function f1(a) { var b = 1; //f1 Scope contains a, ...

9. DedeCms dedecms How to remove... From copyright Power by DedeCms

Many webmasters are using dedecms In the process of building the station , A lot of people will call dedecms Self contained powerby label , In this way, there will be more in the copyright information Power by DedeCms This connection . Today I'll show you how to remove . Tools / raw material de ...

10. see python Internal module command , Built in functions , see python The installed module commands

see python Internal module command , Built in functions , see python The installed module commands It can be used dir(modules) Or use pip list Or use help('modules') Or use python -m  ...