Загружаем каталог…
Загружаем каталог…
A. Nearly Lucky Number time limit per test2 seconds memory limit per test256 megabytes Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky digits in it is a lucky number. He wonders whether number n is a nearly lucky number. Input The only line contains an integer n (1 ≤ n ≤ 1018). Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin, cout streams or the %I64d specificator. Output Print on the single line "YES" if n is a nearly lucky number. Otherwise, print "NO" (without the quotes). cpp #include<iostream> #include<string> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s; cin >> s; int cnt = 0; for (char i : s) { if (i == '4' || i == '7') cnt++; } if (cnt == 4 || cnt == 7)cout << "YES"; else cout << "NO"; return 0; } c# using System; using System.IO; using System.Linq; using System.Text; using System.Threading; class Program { static BufferedStream sb = new BufferedStream(Console.OpenStandardInput()); static StreamReader sr = new StreamReader(new BufferedStream(Console.OpenStandardInput()), Encoding.Default); static StreamWriter sw = new StreamWriter(new BufferedStream(Console.OpenStandardOutput()), Encoding.Default); static int ReadInt() { int c = sb.ReadByte(); while (c <= 32) { if (c == -1) return -1; c = sb.ReadByte(); } bool neg = false; if (c == '-') { neg = true; c = sb.ReadByte(); } int val = 0; while (c > 32) { val = val * 10 + (c - '0'); c = sb.ReadByte(); } return neg ? -val : val; } static void Solve() { string s = sr.ReadLine(); int cnt = s.Count(x => x == '4' || x == '7'); if (cnt == 4 || cnt == 7) sw.Write("YES"); else sw.Write("NO"); sw.Flush(); } static void Main(string[] args) { Thread thread = new Thread(Solve, 1024 * 1024 * 32); thread.Start(); thread.Join(); } } python3 import sys input = sys.stdin.readline s=input().rstrip() cnt=sum(1 for x in s if x=='4' or x=='7') if cnt==4 or cnt==7: print("YES") else: print("NO")
То, что RADAR обнаружил и классифицировал для этой возможности. Это опубликованный источником текст, а не подтверждение, что предложение ещё действует.
[2454일] A. Nearly Lucky Number (성공). A. Nearly Lucky Number time limit per test2 seconds memory limit per test256 megabytes Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a…
Открыть источник