Pagini recente » Cod sursa (job #1119204) | Cod sursa (job #2264878) | Cod sursa (job #2563577) | Cod sursa (job #2135393) | Cod sursa (job #1821245)
#include <fstream>
#include <cstring>
std::ofstream t ("nunta.out");
struct hugeVal{
private:
short index;
static unsigned const short SIZE=0x100;
public:
short num[SIZE]{0};
inline hugeVal &operator = (hugeVal n){
memcpy(num,n.num,SIZE);
return *this;}
inline hugeVal &operator += (hugeVal target){
bool remainder=0;
for (index=0;index<SIZE;++index){
num[index]+=remainder+target.num[index];
if (num[index]>9)
remainder=1,num[index]%=10;
else remainder=0;}
return *this;
}
void print(){
index=SIZE-1;
while (!num[index]) --index;
while (index>=0) t<<num[index],--index;
}
};
int main()
{
std::ifstream f ("nunta.in");
std::ios_base::sync_with_stdio(false);
short n;
f>>n;
hugeVal a,b,aux;
b.num[0]=1;
LOOP:
--n;
aux=b;
b+=a;
a=aux;
if (n>1) goto LOOP;
b.print();
return 0;
}