Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
要用龍龍int#include <iostream> #include <stdio.h> using namespace std; int main() { long long int p4[20]; p4[0] = 1; for(int i = 1; i < 20; i++) p4[i] = p4[i-1]*4; long long int a1[20], aq[20]; a1[2] = 2, aq[2] = 0; for(int n = 3; n < 20; n++){ aq[n] = 2*(a1[n-1]+aq[n-1]); a1[n] = 2*(aq[n-1]+a1[n-1]/2+p4[n-2]); } while(1){ int N; scanf("%d", &N); if(!(~N)) break; if(N<=2) printf("%d: 0\n", N); else{ printf("%d: %I64d\n", N, a1[N]+aq[N]-(1<<N)+2); } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator