A / B HDU-1576 (simple topic number)

# Problem Description
claim $ (A / B) $% $ 9973 $, but due to the large A, we only give $ n (n = A $% $ 9973) $ ( our given shall be $ A $ $ B $ divisible, and $ gcd (B, 9973) = 1) $.
## Input
of the first row of data is a $ T $, $ T $ expressed set of data.
There are two each data number $ n (0 <= n < 9973) $ and $ B (1 <= B < = 10 ^ {9}) $.
## Output
corresponding to each data output $ (A / B) $% $ 9973 $.
### Sample Input

2
1000 53
87 123456789

### Sample Output
>7922
6060

Thinking:
  lists of problem:
    $ \ left \ {\ Array the begin {C} {9973} A = K * \\ + n-
A / B = C \\
C = P * 9733 + X \ Array End {} \ . right $
  
i.e. $ X $ is the answer we want, simultaneous equations available
  $ K * 9973 = B * P * 9973 + B * xn $;
i.e. $ (B * Xn) $% $ 9973 == 0 $;
Since so much data a modulo operation is required, otherwise it will exceed $ $ int range
modulo operation:
    $ \ left \ {\ {C} the begin Array} {(a + B) \% C == (a \% B + C \% C) \% \\ C \\
(ab &) \% C == (A \% CB \% C) \% C;
\\\\
(A * B) \ C ==% ( a \% c * b \% c) \% c; \ end {array} \ right $.

See specific operation codes ヾ (≧ O ≦) 〃 wailing ~:

#define N 9973
#include<iostream>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,b;
        cin>>n>>b;
        int i;
        for(i=0;i<N;i++)
        {
            if((((b%N)*i)%N-n)%N==0)
                break;
        }
        cout<<i<<endl;
    }
    return 0;
}

** == practice is the sole criterion for testing truth == **

Guess you like

Origin www.cnblogs.com/dwj-2019/p/11344364.html