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 |
如此大水,怎么木人做#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator