慧通编程——k的幂(课程7)
题目描述
输入一个正整数k,输出:k k*k k*k*k……,当超过8位数时停止。
输入格式
第一行1个整数k,范围在[2,15]。
输出格式
一行,多个k的幂。
输入/输出例子1
输入:
15
输出:
15 225 3375 50625 759375 11390625
理解
范围为[0,9999999]
代码
#include<bits/stdc++.h>
using namespace std;
int main(){ long long a,s=1;cin>>a;while(s*a<=99999999){s=s*a;cout<<s<<" ";}return 0;
}
注:必须要开long long,不然有可能会超范围