Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,673

(m-m+1)???

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

**Online**

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 90,737

Looks like a typo,

Since m>=n it probably should read (m-n+1).

**In mathematics, you don't understand things. You just get used to them.**

**I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,673

Task :: Kvadratici

In planar rectangular integer grid dimension n x m (are nm squares). How many different squares are in this grid which have corners on integer coordinate (sides of this squares doesn't have to be parallel with sides of grid) ?

INPUT:

In first and only row of standard input are two numbers n and m - dimension of rectangular grid (1 <= n, m <= 10^9).

OUTPUT:

Let K be needed number of squares. On standard input write modulo with division K with 10^9 + 7.

Notes:

In 40% tests 1 <= n, m <= 100

In 60% tests 1 <= n, m <= 1.000

In 80% tests 1 <= n, m <= 1.000.000

Input:

2 3

Output:

10

Input:

500 501

Output:

271062715

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

**Online**

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 90,737

I am not following you what are you looking for that was not already given?

**In mathematics, you don't understand things. You just get used to them.**

**I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,673

well the complexity of the algorithm that solves this problem should be O(1) as i was told.

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

**Online**

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 90,737

You mean a linear function?

**In mathematics, you don't understand things. You just get used to them.**

**I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,673

yes.

Here lies the reader who will never open this book. He is forever dead.

**Online**

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 90,737

Just fit a straight line between the two points you know and interpolate between them.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,673

what do you mean?

Here lies the reader who will never open this book. He is forever dead.

**Online**

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 90,737

You have:

(23,10) and (500501,271062715)

**In mathematics, you don't understand things. You just get used to them.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,673

hi bobbym

the should algorithm should always have the same execution time.

Here lies the reader who will never open this book. He is forever dead.

**Online**

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 90,737

That is where I am getting confused, an algorithm could be a process, like a computer program.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,673

yes,and that is what i need.

Here lies the reader who will never open this book. He is forever dead.

**Online**

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 90,737

Hi anonimnystefy;

In order for a an algorithm to have about the same execution time it would have to be a formula.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,673

that's what i'm looking for

Here lies the reader who will never open this book. He is forever dead.

**Online**

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 90,737

Hi;

How many do you count for this?

**In mathematics, you don't understand things. You just get used to them.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,673

hi bobbym

24. that's including the tilted squares,because that problem says to include those.

Here lies the reader who will never open this book. He is forever dead.

**Online**

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 90,737

I can do better than that, I see 26 but the formula I have sees 30...

**In mathematics, you don't understand things. You just get used to them.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,673

oh,i forgot some sqrt(2)*sqrt(2) squares.sorry.

so what would the formula be?

Here lies the reader who will never open this book. He is forever dead.

**Online**

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 90,737

Your new total then is 26?

**In mathematics, you don't understand things. You just get used to them.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,673

no,it's 30.

Here lies the reader who will never open this book. He is forever dead.

**Online**

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 90,737

Very good! The old have very sharp eyes indeed.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,673

there are the ones with sides of sqrt(3),sqrt(2) and 1.

the old have sharp eyes?you're confusing me now.you told me you were 8 or 9 years old.

Here lies the reader who will never open this book. He is forever dead.

**Online**

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 90,737

Yes, and to me you are an old timer. Ready for retirement. But with sharp eyes.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,673

ok.so what's the conclusion on this? what's the formula?

Here lies the reader who will never open this book. He is forever dead.

**Online**