#include #include #include #include using namespace std; typedef long long LL; struct fac { LL fz,fm; fac(){} fac (LL a,LL b):fz(a),fm(b) {} fac fix() { LL d=__gcd(fz,fm); return fac(fz/d,fm/d); } fac operator + (const fac & b) const { return fac(fz*b.fm+fm*b.fz,fm*b.fm).fix(); } fac operator * (const fac & b) const { return fac(fz*b.fz,fm*b.fm).fix(); } fac operator / (const fac & b) const { return fac(fz*b.fm,fm*b.fz).fix(); } fac operator - (const fac & b) const { return fac(fz*b.fm-fm*b.fz,fm*b.fm).fix() ;} }; struct node { fac xs; int d[5],x[5]; node () { xs=fac(1,1); for(int i=0;i<5;i++) { d[i]=x[i]=0;} } node operator * (const node & b) const { node ans; ans.xs=xs*b.xs; for(int i=0;i<5;i++) { ans.d[i]=d[i]+b.d[i]; ans.x[i]=x[i]+b.x[i]; } return ans; } bool operator < (const node & b) const { for(int i=0;i<5;i++) { if(d[i]!=b.d[i]) return d[i] dep[10],ans; vector v_mult(vector & a,vector & b) { vector ans; int s1=a.size(),s2=b.size(); for(int i=0;i v_exp(vector & a,int b) { vector c=a; while(--b){ c=v_mult(c,a); } return c; } void init() { node a; dep[5].push_back(a); for(int i=4;i>=0;i--){ int s=dep[i+1].size(); vector tmp; node b; b.d[i]=1; tmp.push_back(b); for(int j=0;j q=v_exp(tmp,dep[i+1][j].x[i]+1); int s1=q.size(); for(int k=0;k=0;i--) { d[i]=min(d[i],d[i+1]); if(d[i]<0) return; } fac p=cal(); if(t) ans=ans+p; else ans=ans-p; return; } a[s]=1; dfs(ans,s+1,1-t); a[s]=0; dfs(ans,s+1,t); } fac solve() { while(n<5){ tt[n].s2=1; tt[n++].d=2000; } fac ans=fac(0,1); dfs(ans,0,1); for(int i=0;i<5;i++) ans.fm=ans.fm*tt[i].s2; return ans.fix(); } int main() { init(); while(scanf("%d",&n)&&n){ for(int i=0;itt[i].d) { flag=0;break;} } else { tt[i-1].d=min(tt[i-1].d,tt[i].d-tt[i].s1); } for(int j=i;j=ans.fm) puts("Congratulations!"); else printf("%I64d/%I64d\n",ans.fz,ans.fm); } } }