原题链接:https://www.luogu.com.cn/problem/P2152
Code1(Java):
import java.util.*;
import java.math.*;
public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
BigInteger a = cin.nextBigInteger();
BigInteger b = cin.nextBigInteger();
System.out.println(a.gcd(b));
}
}
Code2(Python):
import fractions
print(fractions.gcd(int(input()),int(input())))
Code3(Python):
//更相减损法
def gcd(a,b):
while(a!=b):
if(a>b):
a-=b
else:
b-=a
return a
print(gcd(int(input()),int(input())))
Code4(Python):
//辗转相除法
def gcd(a,b):
while(a!=0):
b%=a
t=a
a=b
b=t
return b
print(gcd(int(input()),int(input())))
原题链接:hhttps://www.luogu.com.cn/problem/P1414
Code(C++):
#include
#define ll long long
using namespace std;
const int maxn=0x3f3f3f3f;
const int pi=acos(-1.0);
const int mod=10007;
int a[1001000];
inline int read(){
char c=getchar(); int num=0;
for(;!isdigit(c);c=getchar());
for(;isdigit(c);c=getchar())
num=num*10+c-'0';
return num;
}
ll q_pow(ll a, ll b, ll Mod){
ll ans=1,base=a;
while(b){
if(b&1) ans=ans*base%Mod;
base=base*base%Mod;
b>>=1;
}
return ans;
}
ll gcd(ll a, ll b){
return b==0?a:gcd(b,a%b);
}
int main(){
int n=read(),maxn=0;
for(int i=1;i<=n;i++){
int x; x=read();
maxn=max(maxn,x);
for(int j=1;j*j<=x;j++){
if(x%j==0){
a[j]++;
if(x!=j*j) a[x/j]++;
}
}
}
for(int i=1;i<=n;i++){
while(a[maxn]<i) maxn--;
cout<<maxn<<endl;
}
return 0;
}
原题链接:https://www.luogu.com.cn/problem/P1134
Code1(C++):
#include
#include
#include
#include
#include
#define ll long long
using namespace std;
const int maxn=0x3f3f3f3f;
const int pi=acos(-1.0);
inline int read(){
char c=getchar(); int num=0;
for(;!isdigit(c);c=getchar());
for(;isdigit(c);c=getchar())
num=num*10+c-'0';
return num;
}
int m=0;
int f(int x){
int y=x;
while(y%2==0){
m++;
y/=2;
}
while(y%5==0){
m--;
y/=5;
}
return y;
}
int main(){
int n=read(),ans=1;
for(int i=2;i<=n;i++)
ans=(ans*f(i))%10;
for(int i=1;i<=m;i++)
ans=(ans*2)%10;
cout<<ans<<endl;
return 0;
}
Code2(C++):
#include
#define ll long long
using namespace std;
const int maxn=0x3f3f3f3f;
const int pi=acos(-1.0);
inline int read(){
char c=getchar(); int num=0;
for(;!isdigit(c);c=getchar());
for(;isdigit(c);c=getchar())
num=num*10+c-'0';
return num;
}
int main(){
ll n=read(),ans=1;
for(int i=1;i<=n;i++){
ans*=i;
while(ans%10==0)
ans/=10;
ans%=100000000;
}
cout<<ans%10<<endl;
return 0;
}
原题链接:https://www.luogu.com.cn/problem/P1313
Code(C++):
#include
#define ll long long
using namespace std;
const int maxn=0x3f3f3f3f;
const int pi=acos(-1.0);
const int mod=10007;
ll a,b,k,n,m,f[1010][1010];
inline int read(){
char c=getchar(); int num=0;
for(;!isdigit(c);c=getchar());
for(;isdigit(c);c=getchar())
num=num*10+c-'0';
return num;
}
void yanghui(){
f[1][1]=1;
for(int i=2;i<=k+1;i++)
for(int j=1;j<=i;j++)
f[i][j]=(f[i-1][j]%mod+f[i-1][j-1]%mod)%mod;
}
ll q_pow(ll a, ll b, ll Mod){
ll ans=1,base=a;
while(b){
if(b&1) ans=ans*base%Mod;
base=base*base%Mod;
b>>=1;
}
return ans;
}
int main(){
cin>>a>>b>>k>>n>>m;
yanghui();
cout<<(((f[k+1][k+1-n]%mod)*q_pow(a,n,mod))%mod)*q_pow(b,m,mod)%mod<<endl;
return 0;
}