Pastebin
API
tools
faq
paste
Login
Sign up
SHARE
TWEET
AlexAvram
#1608
AlexAvram
Jan 16th, 2023
83
0
Never
Add comment
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!
C++
0.86 KB
| None
|
0
0
raw
download
clone
embed
print
report
//problema #1608
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
using
namespace
std
;
ifstream f
(
"sortare_divizori.in"
)
;
ofstream g
(
"sortare_divizori.out"
)
;
short
nrdiv
(
int
a
)
{
int
d
=
1
, rez
=
0
;
for
(
d
=
1
;
d
*
d
<
a
;
++
d
)
if
(
a
%
d
==
0
)
rez
+
=
2
;
if
(
d
*
d
==
a
)
++
rez
;
return
rez
;
}
bool
comp
(
pair
<
int
,
int
>
A, pair
<
int
,
int
>
B
)
{
if
(
A.
second
<
B.
second
)
return
true
;
else
if
(
A.
second
==
B.
second
&&
A.
first
>
B.
first
)
return
true
;
return
false
;
}
vector
<
pair
<
int
,
int
>>
v
;
int
main
(
)
{
short
n
;
int
x
;
f
>>
n
;
v.
resize
(
n
+
1
)
;
int
i
;
for
(
i
=
1
;
i
<=
n
;
++
i
)
{
f
>>
x
;
v
[
i
]
=
make_pair
(
x, nrdiv
(
x
)
)
;
}
sort
(
v.
begin
(
)
, v.
end
(
)
, comp
)
;
for
(
i
=
n
;
i
>=
1
;
--
i
)
g
<<
v
[
i
]
.
first
<<
" "
;
return
0
;
}
Advertisement
Add Comment
Please,
Sign In
to add comment
Public Pastes
Untitled
1 hour ago | 9.58 KB
Untitled
3 hours ago | 8.23 KB
Yu-Gi-Oh! Forbidden Memories: 100% Run - FAQ
4 hours ago | 2.76 KB
Untitled
5 hours ago | 11.29 KB
Untitled
7 hours ago | 8.53 KB
Untitled
7 hours ago | 11.47 KB
Untitled
9 hours ago | 10.81 KB
Untitled
11 hours ago | 12.67 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!
AltStyle
によって変換されたページ
(->オリジナル)
/
アドレス:
モード:
デフォルト
音声ブラウザ
ルビ付き
配色反転
文字拡大
モバイル