Can anyone help ? I can't understand this recursion function

Правка en2, от Spam_498002, 2021-10-15 16:24:55

https://codeforces.net/contest/96/problem/B

==================#include<bits/stdc++.h> using namespace std; typedef long long ll; vector a; ll N; void dfs(ll now, int four, int seven) { if (now > 100000000000ll) return; if (four == seven) {a.push_back(now);} //cout<<now<<endl; dfs(now * 10 + 4, four + 1, seven); dfs(now * 10 + 7, four, seven + 1); }

int main() { cin >> N; a.clear(); dfs(0, 0, 0); sort(a.begin(), a.end()); int u = 0; for (; a[u] < N; ++u); cout << a[u] << endl;

return 0;

}

Теги help, blog, problem solving

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en4 Английский Spam_498002 2021-10-15 16:27:14 469
en3 Английский Spam_498002 2021-10-15 16:25:53 20 Tiny change: 'em/B\n\n\n\n==================#include<b' -> 'em/B\n\n\n#include<b'
en2 Английский Spam_498002 2021-10-15 16:24:55 70 (published)
en1 Английский Spam_498002 2021-10-15 16:23:17 540 Initial revision (saved to drafts)