Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #define debug(l) cerr<<" bug : "<<#l<<' '<<l<<'\n';
- #include "bits/stdc++.h"
- using namespace std;
- #define all(a) a.begin(), a.end()
- typedef long long ll;
- typedef long double ld;
- // reshenie zdec
- ll dfs(ll n) {
- if (n > 30) {
- return n * n + 5 * n + 4;
- }
- if (n % 2 == 0) {
- return dfs(n + 1) + 3 * dfs(n + 4);
- }
- else {
- return 2 * dfs(n + 2) + dfs(n + 5);
- }
- }
- signed main() {
- ll ans = 0;
- for (ll i = 1; i <= 1000; i++) {
- ll cur = dfs(i);
- string s = to_string(cur);
- ll sum = 0;
- for (ll j = 0; j < s.size(); j++) {
- sum += s[j] - '0';
- }
- if (sum == 27) {
- ans++;
- }
- }
- cout << ans << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement