tags: answer
a,b Mutual qualitya,b Mutual qualityIfx,y(set x<y) Mutual quality:
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.
k>x*y if we want to use x, y to spell out kk=p*y+c(0<c<y && p>=x)Again
nx mod y = c and n < p , k = n * x + (p-n) * y
k must be spelled out by x, y
It can be seen that the k we require must be <x*y
also
x*y
y (mod y)
x(y-1)
y-x (mod y)
x(y-1)-(y-1)
1-x
(x-1)(y-1)
1-x
(x-1)(y-1)-1
-x
again
x, y is a positive integer
-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;
}
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...
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...
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...
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 [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...
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...
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 ...
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...
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...
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...