본문 바로가기

Algorithm/Implementation

(C++) - 백준(BOJ) 4696 : St. lves

반응형

https://www.acmicpc.net/problem/4696

 

4696번: St. Ives

Input consists of multiple data sets. Each data set consists of a line with a single floating point number number representing the numbers of wives, sacks per wife, cats per sack, and kittens per cat that Robert encountered that year. End of input is indic

www.acmicpc.net

간단 구현문제였습니다.

📕 풀이방법

📔 입력 및 초기화

공식을 적용할 a를 선언 후 입력받습니다.

📔 정답출력

공식을 적용한 결과를 형식에 맞게 출력합니다.


📕 Code

#include <bits/stdc++.h>
using namespace std;
double a;
int main(){
  while(1){
    cin >> a;
    if(a == 0) break;
    printf("%.2f\n", 1 + a + pow(a,2) + pow(a,3) + pow(a,4));
  }
}

*더 나은 내용을 위한 지적, 조언은 언제나 환영합니다.