Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int sum_of_digit(int n)
- {
- if (n == 0)
- return 0;
- return (n%10+sum_of_digit(n/10));
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- int t,a,n,res=0,k;
- cin>>t;
- while(t--){
- cin>>a>>n;
- res=pow(a,n);
- k=sum_of_digit(res);
- cout<<k<<"\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement