Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

要用龍龍int

Posted by KatrineYang at 2016-09-22 10:56:11 on Problem 1351
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator