Toggle navigation
Home
Latest pastes
FAQ
Random
Register
Login
Code #3
SUBMITTED BY:
Guest
DATE:
Nov. 30, 2014, 7:26 p.m.
FORMAT:
C++
SIZE:
1.1 kB
Raw
Download
Tweet
HITS:
1198
Go to comments
Report
#include
<iostream>
// SUMA PIERWSZYCH
using
namespace
std
;
bool
tab
[
1000000
];
void
s
(){
for
(
int
i
=
2
;
i
*
i
<=
1000000
;
i
++
)
{
if
(
!
tab
[
i
])
for
(
int
j
=
i
*
i
;
j
<=
1000000
;
j
+=
i
)
tab
[
j
]
=
1
;
}
}
int
main
()
{
s
();
int
n
;
bool
mam
;
while
(
cin
>>
n
)
{
if
(
n
!=
0
)
{
if
(
n
%
2
==
0
)
{
mam
=
false
;
for
(
int
i
=
3
;
i
*
i
<=
n
;
i
+=
2
)
{
if
(
n
-
tab
[
i
]
==
1
)
{
mam
=
true
;
break
;
}
}
if
(
mam
)
cout
<<
"N"
<<
endl
;
else
cout
<<
"T"
<<
endl
;
}
else
{
if
(
tab
[
n
-2
]
==
1
)
cout
<<
"N"
<<
endl
;
else
cout
<<
"T"
<<
endl
;
}
}
else
break
;
}
return
0
;
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus