#1145
Extraprime
Gigel, mare amator de probleme de matematică şi informatică, a observat că unele numere prime au o proprietate interesantă: orice cifră ar elimina dintr-un astfel de număr, numărul obţinut este tot număr prim. A numit astfel de numere numere extraprime. De exemplu, numărul 317
este un număr extraprim: el este număr prim şi, în plus, dacă eliminăm cifra 3
, obţinem 17
, care este prim; dacă eliminăm 1
, obţinem 37
, care este prim; dacă eliminăm 7
, obţinem 31
, care este şi el număr prim.
Spunem că x
este între a
şi b
dacă x≥a
şi x≤b
. Fiind date două valori naturale a
şi b
, să se determine câte numere extraprime există între a
şi b
, precum şi cel mai mic şi cel mai mare număr extraprim dintre a
şi b
.
ONI 2013, Clasa a V-a
Problema | Extraprime | Operații I/O |
extraprime.in /extraprime.out
|
---|---|---|---|
Limita timp | 0.5 secunde | Limita memorie |
Total: 32 MB
/
Stivă 2 MB
|
Id soluție | #49736713 | Utilizator | |
Fișier | extraprime.cpp | Dimensiune | 1.54 KB |
Data încărcării | 13 Martie 2024, 15:47 | Scor / rezultat | Eroare de compilare |
extraprime.cpp:5:17: error: too many decimal points in number Var ciur: Array[1..MAX] Of Boolean; ^ extraprime.cpp:6:14: error: too many decimal points in number P: Array[0..8] Of LongInt = (1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000); ^ extraprime.cpp:30:17: warning: character constant too long for its type [enabled by default] Assign(Fin, 'extraprime.in'); Reset(Fin); ^ extraprime.cpp:31:18: warning: character constant too long for its type [enabled by default] Assign(Fout, 'extraprime.out'); ReWrite(Fout); ^ extraprime.cpp:1:1: error: 'Program' does not name a type Program ExtraPrime; ^ extraprime.cpp:3:1: error: 'CONST' does not name a type CONST MAX = 10000000; ^ extraprime.cpp:5:1: error: 'Var' does not name a type Var ciur: Array[1..MAX] Of Boolean; ^ extraprime.cpp:6:6: error: found ':' in nested-name-specifier, expected '::' P: Array[0..8] Of LongInt = (1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000); ^ extraprime.cpp:6:5: error: 'P' does not name a type P: Array[0..8] Of LongInt = (1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000); ^ extraprime.cpp:7:5: error: 'nr' does not name a type nr, nrmin, nrmax, nrcifre: LongInt; ^ extraprime.cpp:8:5: error: 'Fin' does not name a type Fin, Fout: Text; ^ extraprime.cpp:9:5: error: 'i' does not name a type i, j, a, b: LongInt; ^ extraprime.cpp:11:1: error: 'Function' does not name a type Function Verifica(i: LongInt): Boolean; ^ extraprime.cpp:12:1: error: 'Var' does not name a type Var j, t: LongInt; ^ extraprime.cpp:13:6: error: found ':' in nested-name-specifier, expected '::' v: Boolean; ^ extraprime.cpp:13:5: error: 'v' does not name a type v: Boolean; ^ extraprime.cpp:14:1: error: 'Begin' does not name a type Begin ^ extraprime.cpp:16:5: error: 't' does not name a type t := 1; v := TRUE; ^ extraprime.cpp:16:13: error: 'v' does not name a type t := 1; v := TRUE; ^ extraprime.cpp:18:11: error: expected constructor, destructor, or type conversion before '(' token While (t < i) AND v Do ^ extraprime.cpp:21:7: error: 'j' does not name a type j := i DIV 10 DIV t * t + i MOD t; ^ extraprime.cpp:22:7: error: 'If' does not name a type If NOT ciur[j] Then ^ extraprime.cpp:24:7: error: 't' does not name a type t := t * 10; ^ extraprime.cpp:25:5: error: 'End' does not name a type End; ^ extraprime.cpp:26:5: error: 'Verifica' does not name a type Verifica := v; ^ extraprime.cpp:27:1: error: 'End' does not name a type End; ^ extraprime.cpp:29:1: error: 'Begin' does not name a type Begin ^ extraprime.cpp:30:40: error: expected constructor, destructor, or type conversion before '(' token Assign(Fin, 'extraprime.in'); Reset(Fin); ^ extraprime.cpp:31:11: error: expected constructor, destructor, or type conversion before '(' token Assign(Fout, 'extraprime.out'); ReWrite(Fout); ^ extraprime.cpp:31:44: error: expected constructor, destructor, or type conversion before '(' token Assign(Fout, 'extraprime.out'); ReWrite(Fout); ^ extraprime.cpp:32:11: error: expected constructor, destructor, or type conversion before '(' token ReadLn(Fin, a, b); ^ extraprime.cpp:33:5: error: 'nrcifre' does not name a type nrcifre := 1; ^ extraprime.cpp:34:5: error: 'While' does not name a type While P[nrcifre] < b Do Inc(nrcifre); ^ extraprime.cpp:35:5: error: 'ciur' does not name a type ciur[1] := FALSE; {1 nu este prim} ^ extraprime.cpp:35:39: error: expected unqualified-id before '{' token ciur[1] := FALSE; {1 nu este prim} ^ extraprime.cpp:36:5: error: 'For' does not name a type For i := 2 To P[nrcifre] Do ciur[i] := TRUE; ^ extraprime.cpp:38:5: error: expected unqualified-id before '{' token {ciur} ^ extraprime.cpp:39:5: error: 'i' does not name a type i := 2; ^ extraprime.cpp:40:5: error: 'While' does not name a type While i * i < P[nrcifre] Do ^ extraprime.cpp:43:9: error: 'j' does not name a type j := i * i; ^ extraprime.cpp:44:9: error: 'While' does not name a type While j < P[nrcifre] Do ^ extraprime.cpp:47:13: error: 'j' does not name a type j := j + i ^ extraprime.cpp:49:9: error: 'i' does not name a type i := i + 1 ^ extraprime.cpp:52:5: error: 'nr' does not name a type nr := 0; ^ extraprime.cpp:53:5: error: 'For' does not name a type For i := a To b Do ^ extraprime.cpp:57:17: error: 'If' does not name a type If nr = 1 Then nrmin := i ; ^ extraprime.cpp:58:17: error: 'nrmax' does not name a type nrmax := i; ^ extraprime.cpp:59:13: error: 'End' does not name a type End; ^ extraprime.cpp:60:12: error: expected constructor, destructor, or type conversion before '(' token WriteLn(fout, nr); ^ extraprime.cpp:61:12: error: expected constructor, destructor, or type conversion before '(' token WriteLn(fout, nrmin); ^ extraprime.cpp:62:12: error: expected constructor, destructor, or type conversion before '(' token WriteLn(fout, nrmax); ^ extraprime.cpp:63:10: error: expected constructor, destructor, or type conversion before '(' token Close(Fout); ^ extraprime.cpp:64:1: error: 'End' does not name a type End. ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Extraprime face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.