URI 1532 Throwing Balls - Solution in C++ | Ad Hoc
URI Online Judge Solution 1532 Throwing Balls | Ad Hoc
URI Main Problem Link - 1532 Throwing Balls - https://www.urionlinejudge.com.br/judge/en/problems/view/1532
Problem Name: URI Problem 1532 Throwing Balls
Problem Number : URI Problem 1532 Throwing Balls Solution
Online Judge : URI Online Judge Solution
Level: Ad Hoc
Solution Language : C plus plus
URI Solution 1532 Throwing Balls Code in CPP:
#include <cstdio> #define SC2(a, b) scanf("%d %d", &a, &b) bool check(int v, int n) { int p = 0, i; while(v) { for(i = 0; i <= v; i++, p += v) if(p == n) return true; p -= v; v--; } return false; } int main(int argc, char const *argv[]) { bool b; int n, v, i; while(SC2(n, v) && (n || v)) { b = false; for(i = 1; i <= v; i++) { if(check(i, n)){ b = true; break; } } printf("%s\n", b ? "possivel" : "impossivel"); } }
No comments:
Write commentsTo know more about the problem, give us your valuable commment. We'll try to help you. Thanks