70,021
社区成员




#include <iostream>
#include <string.h>
#include <cstdio>
#include <stdlib.h>
using namespace std;
struct Node
{
int data;
struct Node *next;
struct Node *pre;
};
typedef struct Node Node, *PNode;
struct FrontNode
{
PNode head;
PNode tail;
};
typedef FrontNode DuLink, *PDuLink;
/******************************/
/* 建立 */
/******************************/
void CreateList(DuLink *h)
{
h->head = h->tail = (PNode)malloc(sizeof(Node));
h->head->data = 0;
PNode p = h->head;
for(int i = 0; i < 600; i++)
{
PNode q;
q = (PNode)malloc(sizeof(Node));
q->data = 0;
p->next = q;
q->pre = p;
p = q;
}
h->tail = p;
}
int main()
{
DuLink sum;
CreateList(&sum);
DuLink rn;
CreateList(&rn);
// rn.tail->pre->data = 2;
// sum.tail->pre->data = 1;
rn.head->next->data = 2;
sum.head->next->data = 2;
for(int n = 1; n < 2000; n++)
{
PNode p = rn.tail->pre, q;
int ret = 0;
while(p!=NULL)
{
int temp = (p->data*n+ret);
//cout << temp << endl;
p->data = temp%10;
ret = temp/10;
p = p->pre;
}
//cout << "乘法" << endl;
p = rn.head->next;
ret = 0;
while(p)
{
int temp = p->data+ret*10;
p->data = temp/(2*n+1);
ret = temp%(2*n+1);
p = p->next;
}
//cout << "除法" << endl;
p = rn.tail->pre;
q = sum.tail->pre;
ret = 0;
while(q)
{
int temp = p->data + q->data + ret;
q->data = temp%10;
ret = temp/10;
p = p->pre;
q = q->pre;
}
//cout << "加法" << endl;
}
PNode p = sum.head->next;
int k;
cin >> k;
int cnt = 0;
while(cnt <= k)
{
if(cnt == 0)
cout << p->data << ".";
else
cout << p->data;
p = p->next;
cnt++;
}
cout << endl;
}
#include <iostream>
#include <string.h>
#include <cstdio>
#include <stdlib.h>
using namespace std;
struct Node
{
int data;
struct Node *next;
struct Node *pre;
};
typedef struct Node Node, *PNode;
struct FrontNode
{
PNode head;
PNode tail;
};
typedef FrontNode DuLink, *PDuLink;
/******************************/
/* 建立 */
/******************************/
void CreateList(DuLink *h)
{
h->head = (PNode)malloc(sizeof(Node));
h->tail = (PNode)malloc(sizeof(Node));
h->head->pre = NULL;
h->head->next = NULL;
h->tail->pre = NULL;
h->tail->next = NULL;
h->head->data = 0;
PNode p = h->head;
for(int i = 0; i < 600; i++)
{
PNode q;
q = (PNode)malloc(sizeof(Node));
q->data = 0;
p->next = q;
q->pre = p;
p = q;
}
h->tail = p;
}
int main()
{
DuLink sum;
CreateList(&sum);
DuLink rn;
CreateList(&rn);
// rn.tail->pre->data = 2;
// sum.tail->pre->data = 1;
rn.head->next->data = 2;
sum.head->next->data = 2;
for(int n = 1; n < 2000; n++)
{
PNode p = rn.tail->pre, q;
int ret = 0;
while(p!=rn.head)
{
int temp = (p->data*n+ret);
//cout << temp << endl;
p->data = temp%10;
ret = temp/10;
p = p->pre;
}
//cout << "乘法" << endl;
p = rn.head->next;
ret = 0;
while(p!=rn.tail)
{
int temp = p->data+ret*10;
p->data = temp/(2*n+1);
ret = temp%(2*n+1);
p = p->next;
}
//cout << "除法" << endl;
p = rn.tail->pre;
q = sum.tail->pre;
ret = 0;
while(q!=sum.head)
{
int temp = p->data + q->data + ret;
q->data = temp%10;
ret = temp/10;
p = p->pre;
q = q->pre;
}
//cout << "加法" << endl;
}
PNode p = sum.head->next;
int k;
cin >> k;
int cnt = 0;
while(cnt <= k)
{
if(cnt == 0)
cout << p->data << ".";
else
cout << p->data;
p = p->next;
cnt++;
}
cout << endl;
}