總時間限制:
1000ms
內存限制:
65536kB
// 在此處補充你的代碼
描述
輸入x1 x2 x3 x4 x5 ,輸出y = x5^5 + x4^4 + x3^3 + x2^2 + x1^1 + 1的y的值
#include <algorithm> #include <iostream> #include <stack> #include <queue> #include <vector> #include <cstring> #include <cstdlib> #include <string> #include <cmath> #include <map> #include <set> using namespace std; class MyFunc {
}; int main() { int n; cin >> n; while(n--) { vector<MyFunc> v; for (int i = 0; i < 5; ++i) v.push_back(MyFunc(i+1)); int ans = 1; for (int i = 0; i < 5; ++i) { int m; cin >> m; ans += v[i](m); } cout << ans <<endl; } }
輸入
多組數據。第一行是數據組數 n
每組數據爲一行,5個整數,x1 x2 x3 x4 x5。數值不大,不必考慮溢出
輸出
對每組數據,輸出一個整數y, y = x5^5 + x4^4 + x3^3 + x2^2 + x1^1 + 1
樣例輸入
2 2 2 2 2 2 1 1 1 1 1
樣例輸出
63 6
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <map>
#include <set>
using namespace std;
class MyFunc
{
// 在此處補充你的代碼
public:
int mult;
MyFunc(int i):mult(i){}
int operator()(int m) {
return pow(m, mult);
}
//
};
int main()
{
int n;
cin >> n;
while(n--) {
vector<MyFunc> v;
for (int i = 0; i < 5; ++i)
v.push_back(MyFunc(i+1));
int ans = 1;
for (int i = 0; i < 5; ++i)
{
int m;
cin >> m;
ans += v[i](m);
}
cout << ans <<endl;
}
}