백준 2921번: 도미노

danbibibi·2022년 4월 9일
0

문제

문제 바로가기> 백준 2921번: 도미노

풀이

규칙을 찾아 반복문을 이용하여 구현해주었다!

#include<iostream>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int N, ans=0; cin >> N;
    for(int i=0; i<=N; i++){
        for(int j=0; j<=i; j++) ans+=(i+j);
    }
    cout << ans;
}
profile
블로그 이전) https://danbibibi.tistory.com

0개의 댓글