답안 #82798

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
82798 2018-11-01T18:37:29 Z xiaowuc1 Pot (COCI15_pot) C++14
50 / 50
2 ms 588 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll powpow(ll b, ll e) {
	ll r = 1;
	while(e) {
		if(e%2) {
			r *= b;
		}
		b *= b;
		e /= 2;
	}
	return r;
}

int main() {
	int n;
	cin >> n;
	ll ret = 0;
	while(n--) {
		string s;
		cin >> s;
		int x = 0;
		for(int i = 0; i < s.size()-1; i++) {
			x *= 10;
			x += s[i] - '0';
		}
		int y = s[s.size()-1] - '0';
		ret += powpow(x, y);
	}
	printf("%lld\n", ret);
}

Compilation message

pot.cpp: In function 'int main()':
pot.cpp:27:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < s.size()-1; i++) {
                  ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 484 KB Output is correct
6 Correct 2 ms 484 KB Output is correct
7 Correct 2 ms 484 KB Output is correct
8 Correct 2 ms 536 KB Output is correct
9 Correct 2 ms 536 KB Output is correct
10 Correct 2 ms 588 KB Output is correct