• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Jan 24th, 2020 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <iostream>
2. #include <fstream>
3. using namespace std;
4. ifstream f("tema.in");
5.     ofstream g("tema.out");
6. void Simplificare(long long a,long long b)
7. {
8.     long long r,auxa,auxb;
9.     auxa=a;
10.     auxb=b;
11.     r=1;
12.     while(r!=0)
13.     {
14.         r=auxa%auxb;
15.         auxa=auxb;
16.         auxb=r;
17.
18.     }
19.     g<<a/auxa<<" "<<b/auxa<<endl;
20.
21. }
22.
23.
24.
25.
26.
27.
28. int main()
29. {
30.  long long n,i,p1,p2,p3,aux2,c = 1,nur,num,aux1,aux3,m,s;
31. f>>n;
32. for(i=0;i<n;i++)
33. {
34.     f>>p1>>p2>>p3;
35.     aux1=p1;
36.     aux2=p2;
37.     aux3=p3;
38.
39.     if(p2 != -1 && p3 == -1)
40.     {
41.         c=1;
42.         while(aux2>0)
43.     {
44.         aux2=aux2/10;
45.         c=c*10;
46.     }
47.     nur=p1*c+p2;
48.
49.     Simplificare(nur,c);
50.     }
51.     if(p2 == -1 && p3 != -1)
52.     {   c=10;
53.         num=9;
54.
55.         while(aux3>10)
56.         {
57.             aux3=aux3/10;
58.             c=c*10;
59.             num=num*10+9;
60.         }
61.
62.         nur=p1*c+p3-p1;
63.
64.         Simplificare(nur,num);
65.     }
66.     if(p2 != -1 && p3 != -1)
67.     {   m=10;
68.         s=1;
69.         c=10;
70.         num=9;
71.         while(aux3>10)
72.         {
73.             aux3=aux3/10;
74.             c=c*10;
75.             m=m*10;
76.             num=num*10+9;
77.
78.         }
79.         while(aux2>1)
80.         {
81.             aux2=aux2/10;
82.             c=c*10;
83.             s=s*10;
84.             num=num*10;
85.         }
86.
87.         nur=p1*c+m*p2+p3-p1*s-p2;
88.
89.         Simplificare(nur,num);
90.     }
91. }
92.     return 0;
93.
94.
95. }
RAW Paste Data
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.
Top