NOIP 2017 Xiaokai's doubts

tags: answer

NOIP 2017 Xiaokai's doubts


Thought

  1. a,b Mutual quality
  2. Find the maximum number k that cannot be expressed
  3. Then ka,b Mutual quality
Here is a conclusion: (provided online)But I am the law of looking for a watch.

Ifx,y(set x<y) Mutual quality:
n x nx\equiv a (mod y) if you double x, you can get

nx mod y ans
x a
2x 2a mod y
3x 3a mod y
4x 4a mod y
y*x y*a mod y

At this time, the value of a just traverses all the numbers in 0 ~ y-1.

Assume k>x*y if we want to use x, y to spell out k

k=p*y+c(0<c<y && p>=x)

Again \because nx mod y = c and n < p , k = n * x + (p-n) * y
\therefore k must be spelled out by x, y

It can be seen that the k we require must be <x*y


also \because x*y \equiv y (mod y)
x(y-1) \equiv y-x (mod y)
x(y-1)-(y-1) \equiv 1-x
(x-1)(y-1) \equiv 1-x
(x-1)(y-1)-1 \equiv -x
again \because x, y is a positive integer
\therefore -x<0, there is no solution for x, y>0
Ok, actually, let’s focus on here.
The code is as follows:

#include<iostream>
using namespace std;
int main()
{
	long long a,b;//a,b must open long long 
	cin>>a>>b;
	cout<<a*b-a-b<<endl;
	return 0;
}

Intelligent Recommendation

d1t1 Xiaokai's doubts

d1t1 Xiaokai's doubts Low Valley Title idea Either find a pattern Or use number theory. Number theory is as follows:reference Code Remember to open long long...

[NOIP2017 improvement group] Xiaokai's doubts

Xiaokai’s doubts Topic background NOIP2017 improvement group DAY1 T1 Description of the topic Xiaokai has two denominations of gold coins, both of which are positive integers and are mutually pr...

# # 3951 JZOJ 5473 Xiaokai's doubts

Subject To pay for commodities with two kinds of gold coins with par value, the par value is p, q, what is the price of the most expensive commodity without change analysis Use an equation px+qy=n(gcd...

[NOIP2017] Xiaokai's doubts in the rematch Day1T1

emmmm is a metaphysical elementary school Mathematical Olympiad. The key is to find the conclusion. The enumeration can only deceive about 60 points. 233 Xiaokai’s doubts Title description Xiaok...

P3951 Xiaokai's doubts / number of buying

P3951 [NOIP2017 upgraded] Xiaokai's doubts / [Blue Bridge Cup 2013 Province] I can't buy Inscription There are two gold coins of two faces in Little Kaidan, both of which are positive integers and mut...

More Recommendation

Doubts problem solution to improve the group noip 2017 Oscar

Topic Portal Subject to the effect: Given x , y x,y x,y, Find the maximum can not be expressed as a x + b y ax+by ax+by Number. answer The answer is provided a n s ans ans。 To meet the requirements of...

[NOIP 2017] Increment the group DAY1 T1 Oscar doubts

emmm seemingly long before going to test NOIP, so I finally began to brush the problem in previous years   【topic】 Subject description: There are two kinds of face value of coins in the hands of ...

[JZOJ6057] [GDOI2019 simulation 2011.3.13] Xiaokai's doubts

Description There is a complete graph of n points, each point has a weight xi, and the edge weight of the edge (i, j) is xi xor xj There are q groups of queries, each query gives v, asks to add all th...

P3951 Xiaokai's doubts (exgcd + number theory)

Title link First of all, this question is used.Saavistration It is known that A, B is a positive integer, GCD (A, B) = 1, which makes the unregulated equation AX + by = k without negative integer solu...

P3951 Xiaokai's doubts (NOIP2017 raise group question 1)

Title description There are two types of gold coins in Xiaokai's hands, both of which are positive integers and mutually prime. There are countless gold coins of each kind. In the case of no change, w...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top