Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream f("error.in");
- ofstream g("error.out");
- typedef int NrMare[1010];
- NrMare x,y;
- int n,a,b;
- void Adunare(NrMare x,NrMare y)
- /// x = x + y
- {
- int i,t=0;
- if(x[0]<y[0])
- x[0]=y[0];
- for(i=1;i<=x[0];i++,t/=10)
- {
- t=x[i]+y[i]+t;
- x[i]=t%10;
- // echivalent x[i]=(t+=x[i]+y[i])%10
- }
- if(t)
- x[++x[0]]=t;
- }
- int main()
- {
- f>>n;
- x[0]=1;
- x[1]=0;
- for(int i=1;i<=n;++i)
- {
- f>>a>>b;
- y[0]=30;
- for(int j=1;j<=30;++j)
- a%=b,a=a*10,y[30-j+1]=a/b;
- Adunare(x,y);
- }
- for(int i=30;i>10;--i)
- g<<x[i]<<' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement