1. 程式人生 > >2018華為筆試題

2018華為筆試題

程式碼:

#include<iostream>
using namespace std;

int main()
{
	long long n, M, N, list[51];
	cin >> n;
	list[0] = 1, list[1] = 2, list[2] = 3, list[3] = 4;
	for (int i = 4; i <= 50; i++)list[i] = list[i - 1] + list[i - 4];
	while (n--)
	{
		cin >> M >> N;
		cout << list[N] * M << endl;
	}
	return 0;
}