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

如此大水,怎么木人做

Posted by KatrineYang at 2016-11-16 13:22:44 on Problem 1538
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
	while(1){
		int n;
		cin >> n;
		if(!n) break;
		int table[16][16];
		for(int i = 1; i <= n; i++) cin >> table[n][i];
		for(int i = n-1; i >= 1; i--){
			for(int j = 1; j <= i; j++){
				table[i][j] = table[i+1][j+1] - table[i+1][j];
			}
		}
		int k;
		cin >> k;
		int ans[16];
		for(int i = 1; i <= n; i++) ans[i] = table[i][i];
		for(int ii = 0; ii < k; ii++){
			for(int i = 1; i < n; i++){
				ans[i+1] += ans[i];
			}
		}
		cout << "Term " << n+k << " of the sequence is " << ans[n] << endl;
	}
	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