알고리즘 문제/BOJ
10448번 유레카 이론
parkit
2018. 12. 29. 12:58
728x90
반응형
https://www.acmicpc.net/problem/10448
처음에 수의 범위가 주어지지 않아서, 당황했는데
그냥 멋대로 설정하고 제출하니까 맞았다.
long long으로 해야되겠지하고 생각했었는데 아니었나보다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #include <iostream> #include <queue> #include <stack> #include <cstdio> #include <vector> #include <cstring> #include <string> #include <math.h> #include <algorithm> #include <map> using namespace std; int Eureka[303] = { 0, }; int result[5050] = { 0, }; int main(void) { int T = 0; for (int i = 1; i <= 300; i++) { Eureka[i] = i*(i + 1) / 2; } for (int a = 1; a <= 300; a++) { for (int b = 1; b <= 300; b++) { for (int c = 1; c <= 300; c++) { if (Eureka[a] + Eureka[b] + Eureka[c] > 5000) continue; result[Eureka[a] + Eureka[b] + Eureka[c]] = 1; } } } scanf("%d", &T); while(T--) { int n = 0; scanf("%d", &n); if (result[n] == 0) printf("0\n"); else printf("1\n"); } return 0; } | cs |
728x90
반응형