| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 38517 | wxy | 【J】T1 | C++ | 通过 | 100 | 227 MS | 260 KB | 949 | 2025-10-15 18:33:43 |
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=55; ll a[N]; void fj(ll x){ for(ll i=2;i<=x;i++){ while(x%i==0&&x){ printf("%lld",i); x/=i; if(x>1) printf("*"); } } } bool isprime(ll x){ if(x<2) return 0; for(int i=2;i*i<=x;i++){ if(x%i==0){ return 0; } } return 1; } int main(){ //freopen("sequence.in","r",stdin); //freopen("sequence.out","w",stdout); ll n,p; //double t1=clock(); scanf("%lld %lld",&n,&p); a[0]=0,a[1]=1; for(int i=2;i<=n;i++){ a[i]=(((2*a[i-1])%p)+(a[i-2]%p))%p; } printf("%lld=",a[n]); if(isprime(a[n])){ printf("%lld\n",a[n]); return 0; } fj(a[n]); printf("\n"); //printf("%lf\n",(clock()-t1)/CLOCKS_PER_SEC); //fclose(stdin); //fclose(stdout); return 0; }