hiho week 279 register

Ended

Participants:46

Verdict:Accepted
Score:100 / 100
Submitted:2019-11-03 13:33:42

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
using namespace std;
long long bb;
long long mark=1,p;
void check(long long a,long long b)
{
    if(b%a==a-1)
    {
        mark=mark*(b/a+1)%p;
        return ;
    }
    mark=mark*(b/a+1)%p;
    check(a-b%a,b);
    return;
}
int main()
{
    long long a;
    scanf("%lld%lld%lld",&a,&bb,&p);
    check(bb,p);
    printf("%lld\n",(long long)(mark%p*a)%p);
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX