nowcoder 牛客小白月赛12

题目链接https://ac.nowcoder.com/acm/contest/392#question

B-华华教月月做数学

python快速幂

ac代码:

t = int(input())
for _ in range(t):
    a, b, c = map(int, input().split())
    print(pow(a, b, c))
    
View Code

G-华华对月月的忠诚

最大公约数,注意要用long long

ac代码:

#include<iostream>
#include<string>
using namespace std;
long long gcd(long long x,long long y){
    if(y==0) return x;
    return gcd(y,x%y);
}
int main()
{
    long long a,b;
    string n;
    cin>>a>>b>>n;
    cout<<gcd(a,b)<<endl;
    return 0;
}
View Code

猜你喜欢

转载自www.cnblogs.com/looeyWei/p/10502678.html