while (cin >> y >> k >> n) { bool flag = false; for (int i = 1; i < n - y; i++) { if ((i + y) % k == 0) { flag = true; cout << i << " "; } } if (!flag) cout << "-1" << endl; else cout << endl; } }
string s, res; intmain(){ cin >> s; res = ""; if (s.length() % 2 != 0) { for (int i = 0; i < s.length() + 1; i += 2) { res += "4"; } for (int i = 0; i < s.length() + 1; i += 2) { res += "7"; } cout << res << endl; return0; } else { for (int i = 0; i < s.length(); i += 2) { res += "7"; } for (int i = 0; i < s.length(); i += 2) { res += "4"; } if (stoll(res) > stoll(s)) { res = ""; bool flag = false; int count = 0; for(int i = 0; i < s.length(); i ++) { if(flag && count < s.length()/2) { count++; res +='4'; continue; } if(s[i] < '4'&& count < s.length()/2) { flag = true; res += '4'; count++; continue; } if(s[i] == '4'&& count < s.length()/2) { res += '4'; count++; continue; } if(s[i] < '7') { res += '7'; flag = true; continue; } if(s[i] =='7') { res += '7'; continue; } } cout << res << endl; } elseif (stoll(res) == stoll(s)) { cout << res << endl; return0;
} elseif (stoll(res) < stoll(s)) { res = ""; for (int i = 0; i < s.length() + 2; i += 2) { res += "4"; } for (int i = 0; i < s.length() + 2; i += 2) { res += "7"; } cout << res << endl; return0; } } }