期望得分:100+100+20=220
实际得分:100+95+20=215
T1 洛谷 P1306 斐波那契公约数
#include<cstdio> #include<cstring> using namespace std; typedef long long LL; LL t[2][2],ans[2][2],r[2][2]; const int mod=1e8; int gcd(int a,int b) { return !b ? a : gcd(b,a%b); } void mul(LL a[2][2],LL b[2][2]) { memset(r,0,sizeof(r)); for(int i=0;i<2;i++) for(int j=0;j<2;j++) for(int k=0;k<2;k++) r[i][j]+=a[i][k]*b[k][j],r[i][j]%=mod; for(int i=0;i<2;i++) for(int j=0;j<2;j++) a[i][j]=r[i][j]; } int main() { int a,b; scanf("%d%d",&a,&b); int p=gcd(a,b); t[0][0]=t[0][1]=t[1][0]=1;; ans[0][0]=ans[0][1]=1; if(p==2 || p==1) { printf("1"); return 0; } p-=2; while(p) { if(p&1) mul(ans,t); mul(t,t); p>>=1; } printf("%lld",ans[0][0]); }