/**************Powered by Graphene Richards**************/ //{ #define FLOAT_PRECISION 6 #define INT_64_MOD "%I64d" #define UNSIGNED_64_MOD "%I64u" #ifdef _MSC_VER #define _CRT_SECURE_NO_DEPRECATE #define _SECURE_SCL 0 #pragma comment(linker,"/STACK:102400000,102400000") #else #pragma warning(disable:4996) #pragma GCC optimize("O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") #endif #if defined(_MSC_VER)||__cplusplus>199711L #define IT(x) auto #define DIT(x) auto #else #define IT(x) __typeof((x).begin()) #define DIT(x) __typeof((x).rbegin()) #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define FAST_RW ios_base::sync_with_stdio(0),cin.tie(0); #define FS(i,a) for(ll i=0;a[i];i++) #define FE(x,ctn) for(IT(ctn) x=(ctn).begin(),_en=(ctn).end();x!=_en;x++) #define EF(x,ctn) for(DIT(ctn) x=(ctn).rbegin(),_en=(ctn).rend();x!=_en;x++) #define FR(i,en) for(ll i=0,_en=(en);i<_en;i++) #define FOR(i,en) for(ll i=1,_en=(en);i<=_en;i++) #define RF(i,en) for(ll i=(en)-1;i>=0;i--) #define ROF(i,en) for(ll i=(en);i>0;i--) #define FFR(i,x,y) for(ll i=(x),_en=(y);i<=_en;i++) #define RFF(i,x,y) for(ll i=(x),_en=(y);i>=_en;i--) #define pc putchar #define pb push_back #define ppb pop_back #define pct __builtin_popcount #define pq priority_queue #define fi first #define se second #define mp make_pair #define pii pair #define pll pair #define pdd pair #define lb(x) (x&(-x)) #define sqr(x) ((x)*(x)) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define clr(x) memset((x),0,sizeof(x)) #define ms(x,v) memset((x),(v),sizeof(x)) #define mc(x,y) memcpy((x),(y),sizeof(y)) #define NL puts(""); #define LB lower_bound #define UB upper_bound #define RAND abs((rand()<<15)^rand()) typedef unsigned ui; typedef long long ll; typedef unsigned long long ull; typedef long double lf; using namespace std; ull gcd(ull a,ull b){if(!b)return a;while(b^=a^=b^=a%=b);return a;} extern const ll MOD; ll ksm(ll a,ll b){ ll res=1; a%=MOD; for(;b;b>>=1){ if(b&1)res=res*a%MOD; a=a*a%MOD; } return res; } #ifdef wmx16835 #include"wmx16835.h" #else #define LOG #define TEL #define PF #define PC #define SF(...) #define SC #define test(...) 0 #define TEST(...) 0 #define TRY(...) #define PP #define SHOW_TIME #endif templatebool In(T1 x,T2 y,T3 z){return x<=y&&x>=z||x<=z&&x>=y;} templateT1 Max(const T1&a,const T2&b){return aT1 Max(const T1&a,const T2&b,const T3&c){return aT1 Min(const T1&a,const T2&b){return aT1 Min(const T1&a,const T2&b,const T3&c){return abool S(T1&a,T2&b){return S(a)+S(b)==2;} templatebool S(T1&a,T2&b,T3&c){return S(a)+S(b)+S(c)==3;} templatebool S(T1&a,T2&b,T3&c,T4&d){return S(a)+S(b)+S(c)+S(d)==4;} templatebool S(T1&a,T2&b,T3&c,T4&d,T5&e){return S(a)+S(b)+S(c)+S(d)+S(e)==5;} templatevoid P(const T1&a){_P(a);pc(' ');} templatevoid P(const T1&a,const T2&b){_P(a);pc(' ');_P(b);pc(' ');} templatevoid PN(const T1&a){_P(a);NL} templatevoid PN(const T1&a,const T2&b){_P(a);pc(' ');_P(b);NL} templatevoid PN(const T1&a,const T2&b,const T3&c){_P(a);pc(' ');_P(b);pc(' ');_P(c);NL} templatevoid PN(const T1&a,const T2&b,const T3&c,const T4&d){_P(a);pc(' ');_P(b);pc(' ');_P(c);pc(' ');_P(d);NL} templatevoid PN(const T1&a,const T2&b,const T3&c,const T4&d,const T5&e){_P(a);pc(' ');_P(b);pc(' ');_P(c);pc(' ');_P(d);pc(' ');_P(e);NL} void PS(int a){printf("%*s",a,"");} template void PA(T*a,int n){ bool f=1; FR(i,n){ if(f)f=0; else pc(' '); _P(a[i]); } NL } template void PA(const T&x){ bool f=1; FE(it,x){ if(f)f=0; else pc(' '); _P(*it); } NL } int kase; const double pi=4*atan(1); const double ep=1e-9; const int INF=0x3f3f3f3f; const ll INFL=0x3f3f3f3f3f3f3f3fll; const ll MOD=1000000007; //} int n; double d[100005][2][12]; double f[100005][2][12],g[100005][2][12]; double A[100005],B[100005]; void init(){ double sum = 0; FR(i,10){ d[2][1][i] = (9 - i) * 1.0; f[2][1][i] = d[2][1][i]; g[2][1][i] = 2*f[2][1][i]; d[2][0][i] = i * 1.0; f[2][0][i] = d[2][0][i]; g[2][0][i] = 2*f[2][0][i]; d[2][0][i] /= 90; d[2][1][i] /= 90; f[2][0][i] /= 90; f[2][1][i] /= 90; g[2][0][i] /= 90; g[2][1][i] /= 90; d[2][0][i] *= 10000000000ll; d[2][1][i] *= 10000000000ll; f[2][0][i] *= 10000000000ll; f[2][1][i] *= 10000000000ll; g[2][0][i] *= 10000000000ll; g[2][1][i] *= 10000000000ll; } A[1] = 1;B[1] = 1; A[2] = 1;B[2] = 2; for(int n=3; n<=100000; n++){ for(int j=0; j<10; j++){ for(int prei=0; prei<2; prei++){ for(int prej=0; prej<10; prej++){ if(prej == j) continue; if(prei == 0){ if(prej < j){ d[n][prei][j] += d[n-1][prei][prej]; f[n][prei][j] += f[n-1][prei][prej]; g[n][prei][j] += g[n-1][prei][prej] + d[n-1][prei][prej]; } else{ d[n][prei^1][j] += d[n-1][prei][prej]; f[n][prei^1][j] += f[n-1][prei][prej] + d[n-1][prei][prej]; g[n][prei^1][j] += g[n-1][prei][prej] + 2*d[n-1][prei][prej]; } } else{ if(prej > j){ d[n][prei][j] += d[n-1][prei][prej]; f[n][prei][j] += f[n-1][prei][prej]; g[n][prei][j] += g[n-1][prei][prej] + d[n-1][prei][prej]; } else{ d[n][prei^1][j] += d[n-1][prei][prej]; f[n][prei^1][j] += f[n-1][prei][prej] + d[n-1][prei][prej]; g[n][prei^1][j] += g[n-1][prei][prej] + 2*d[n-1][prei][prej]; } } } } d[n][0][j] /= 9; d[n][1][j] /= 9; f[n][0][j] /= 9; f[n][1][j] /= 9; g[n][0][j] /= 9; g[n][1][j] /= 9; } double F = 0,G = 0; for(int i=0; i<2; i++){ for(int j=0; j<10; j++){ F += f[n][i][j]; G += g[n][i][j]; } } A[n] = F / 10000000000ll; B[n] = G / F; } } int main(){ SHOW_TIME init(); int T; S(T); while(T--){ S(n); printf("Case #%d:\n",++kase); PN(A[n],B[n]); } } /*********Risoft corporation all rights reserved*********/ /**************Template V2.17 build 20150524*************/