From 9905275b4e89bbfba7925529cddbcc1dba0b0ca7 Mon Sep 17 00:00:00 2001 From: "Paulo H. Lamounier" <53798700+Nanashii76@users.noreply.github.com> Date: Tue, 20 Feb 2024 14:25:57 -0300 Subject: [PATCH] Atcoder contest exercises --- roadmap_atcoder/ABC083B_Some_Sums.cpp | 29 +++++++++++++++++++++++++++ roadmap_atcoder/ABC087B_Coins.cpp | 21 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 roadmap_atcoder/ABC083B_Some_Sums.cpp create mode 100644 roadmap_atcoder/ABC087B_Coins.cpp diff --git a/roadmap_atcoder/ABC083B_Some_Sums.cpp b/roadmap_atcoder/ABC083B_Some_Sums.cpp new file mode 100644 index 0000000..405e6a3 --- /dev/null +++ b/roadmap_atcoder/ABC083B_Some_Sums.cpp @@ -0,0 +1,29 @@ +#include + +int digitsSum(int x) { + + int sum = 0; + + while (x != 0) { + sum += x%10; + x /= 10; + } + + return sum; + +} + +int main(void) { + + int n, a ,b; + std::cin >> n >> a >> b; + + int sum = 0; + + for(int i = 1; i <= n; ++i) + if(digitsSum(i) >= a && digitsSum(i) <= b) + sum += i; + + std::cout << sum << std::endl; + +} \ No newline at end of file diff --git a/roadmap_atcoder/ABC087B_Coins.cpp b/roadmap_atcoder/ABC087B_Coins.cpp new file mode 100644 index 0000000..2f523f4 --- /dev/null +++ b/roadmap_atcoder/ABC087B_Coins.cpp @@ -0,0 +1,21 @@ +#include + +int main(void) { + + int a,b,c,x; + std::cin >> a >> b >> c >> x; + int tot = 0; + + // Analizyng until each coin become zero; + for(int i = 0; i <= a; ++i) + for(int j = 0; j <= b; ++j) + for(int k = 0; k <= c; ++k) { + int sum = 500*i + 100*j + 50*k; + if(sum == x) + tot++; + } + + std::cout << tot << std::endl; + + +} \ No newline at end of file