코딩로그
[백준/BOJ/C++] 11772번 POT 본문
[문제]
The teacher has sent an e-mail to her students with the following task:
"Write a programme that will determine and output the value of X if given the statement:
X=number1^pot1+number2^pot2+⋯+numberN^potN
and it holds that number1, number2 to numberN are integers, and pot1, pot2 to potN one-digit integers." Unfortunately, when the teacher downloaded the task to her computer, the text formatting was lost so the task transformed into a sum of N integers:
X=P1+P2+...+PN
For example, without text formatting, the original task in the form of X=212+1253 became a task in the form of X=212+1253. Help the teacher by writing a programme that will, for given N integers from P1 to PN determine and output the value of X from the original task.
Please note: We know that it holds a N=a⋅a⋅⋯⋅a (N times).
[입력]
The first line of input contains the integer N (1 ≤ N ≤ 10), the number of the addends from the task. Each of the following N lines contains the integer Pi (10 ≤ Pi ≤ 9999, i = 1 ... N) from the task.
[출력]
The first and only line of output must contain the value of X (X ≤ 1 000 000 000) from the original task.
[Source Code]
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
int test;
long long output = 0;
cin >> test;
for(int i = 0; i < test; i++){
int input;
cin >> input;
int one = input % 10;
input /= 10;
output += pow((double)input, one);
}
cout << output;
}
[결과 화면]
'YJ > C++' 카테고리의 다른 글
[백준/BOJ/C++] 5800번 성적 통계 (0) | 2021.12.31 |
---|---|
[백준/BOJ/C++] 4641번 Doubles (0) | 2021.12.31 |
[백준/BOJ/C++] 2703번 Cryptoquote (0) | 2021.12.31 |
[백준/BOJ/C++] 2495번 연속구간 (0) | 2021.12.31 |
[백준/BOJ/C++] 1453번 피시방 알바 (0) | 2021.12.31 |