백준 알고리즘 10448번 : 유레카 이론

Zoo Da·2021년 11월 28일
0

백준 알고리즘

목록 보기
268/337
post-thumbnail

링크

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

sol1) 브루트 포스

#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int int64_t
using namespace std;

vector<int> trangleNumber(1001);

int Sol(int n){
  for(int i = 1; i <= 50; i++) for(int j = 1; j <= 50; j++) for(int k = 1; k <= 50; k++){
    if(trangleNumber[i] + trangleNumber[j] + trangleNumber[k] == n) return 1;
  }  
  return 0;
}

int32_t main() {
  fastio;
  for(int i = 1; i <= 1000; i++) trangleNumber[i] = trangleNumber[i - 1] + i;
  int tc; cin >> tc;
  while(tc--){
    int n; cin >> n;
    cout << Sol(n) << "\n";
  }
}
profile
메모장 겸 블로그

0개의 댓글