Problem hidden
|This problem was hidden by Editorial Board member probably because it has incorrect language|version or invalid test data, or description of the problem is not clear.|

P153PROB - ROUND 3B - Dãy số Catalan

Input

Dòng duy nhất chứa số n (0 <= n <= 5000).

Output

Dòng duy nhất chứa kết quả tìm được.

Example

Input:
3

Output:
14

Được gửi lên bởi:adm
Ngày:2015-03-19
Thời gian chạy:1s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:ASM32-GCC ASM32 MAWK BC C CSHARP C++ 4.3.2 CPP CPP14 COFFEE LISP sbcl DART FORTH GO JAVA JS-RHINO KTLN OCT PAS-GPC PAS-FPC PERL PERL6 PROLOG PYTHON PYTHON3 PY_NBC R RACKET SQLITE SWIFT UNLAMBDA

hide comments
2024-10-29 09:55:06
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;
string nhan(string a, int t){
reverse(a.begin(),a.end());
int nho=0;
string x="";
for(int i=0;i<a.size();i++){
int tm=(a[i]-'0')*t+nho;
x+=char(tm%10+'0');
nho=tm/10;
}
while(nho>0){
x+=char(nho%10+'0');
nho/=10;
}
reverse(x.begin(),x.end());
return x;
}
int main(){
int c[5001]={0};
c[0]=1;c[1]=1;
for(int i=2;i<=sqrt(5001);i++){
if(c[i]==0){
for(int j=i*i;j<5001;j+=i){
c[j]=1;
}
}
}
int n;cin>>n;
n++;
map<int,int> m;
for(int i=n+2;i<=2*n;i++){
int so=i;
for(int j=2;j<=sqrt(so);j++){
if(c[j]==0){
while(so%j==0){
so/=j;
m[j]++;
}
}
}
if(so>1){
m[so]++;
}
}
for(int i=2;i<=n;i++){
int so=i;
for(int j=2;j<=sqrt(so);j++){
if(c[j]==0){
while(so%j==0){
so/=j;
m[j]--;
}
}
}
if(so>1){
m[so]--;
}
}
string an="1";
map<int,int> :: iterator it;
for(it=m.begin();it!=m.end();it++){
for(int i=0;i<(*it).second;i++){
an=nhan(an,(*it).first);
}
}
cout<<an;
return 0;
}
2017-02-16 08:17:51
còn ép phải code số nguyên lớn nữa cơ -_-
2016-04-13 03:31:43
HD:
http://mycodealgorithm.blogspot.com/2016/04/p153prob-round-3b-day-so-catalan_12.html
2015-07-22 13:58:58 Z3r0_L0v3
Sao sai vậy trời. Test nào đây
2015-05-24 08:53:31 TICHPX


Last edit: 2015-05-24 08:54:27
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.