Baidu Star 2019 · Programming Contest - a preliminary round

http://bestcoder.hdu.edu.cn/contests/contest_show.php?cid=861

I did not expect 6:00 began, more than seven began to play, A 1001 and 1005 after hang up. .

 I too dishes

 

1001、Polynomial

Attendance problems. Both the numerator and denominator tends to infinity, and both are polynomial with L'Hospital just fine, the maximum number of comparisons f and g

 1 #include<iostream>
 2 #include<sstream>
 3 #include<fstream>
 4 #include<algorithm>
 5 #include<cstring>
 6 #include<iomanip>
 7 #include<cstdlib>
 8 #include<cctype>
 9 #include<vector>
10 #include<string>
11 #include<cmath>
12 #include<ctime>
13 #include<stack>
14 #include<queue>
15 #include<map>
16 #include<set>
17 #define mem(a,b) memset(a,b,sizeof(a))
18 #define random(a,b) (rand()%(b-a+1)+a)
19 #define ll long long
20 #define ull unsigned long long
21 #define e 2.71828182
22 #define Pi acos(-1.0)
23 #define ls(rt) (rt<<1)
24 #define rs(rt) (rt<<1|1)
25 #define lowbit(x) (x&(-x))
26 using namespace std;
27 const int MAXN=1e3+5;
28 int f[MAXN],g[MAXN];
29 int n;
30 void solve()
31 {
32     for(int i=n-1;i>=0;--i)
33     {
34         if(!f[i]&&!g[i]) continue;
35         if(f[i]&&g[i])
36         {
37             int Gcd=__gcd(f[i],g[i]);
38             cout<<f[i]/Gcd<<'/'<<g[i]/Gcd<<"\n";
39             return ;
40         }
41         else if(f[i])
42         {
43             cout<<"1/0\n";
44             return;
45         }
46         else if(g[i])
47         {
48             cout<<"0/1\n";
49             return; 
50         }
51     }    
52 }
53 int read()
54 {
55     int s=1,x=0;
56     char ch=getchar();
57     while(!isdigit(ch)) {if(ch=='-') s=-1;ch=getchar();}
58     while(isdigit(ch)) {x=10*x+ch-'0';ch=getchar();}
59     return x*s;
60 }
61 int main()
62 {
63     int test=read();
64     while(test--)
65     {
66         n=read();
67         for(int i=0;i<n;++i) f[i]=read();
68         for(int i=0;i<n;++i) g[i]=read();
69         solve();
70     } 
71     return 0;
72 }
View Code

 

1005、Seq

Hit the table to find the law. 6 as one cycle. Here was the draft.

 1 #include<iostream>
 2 #include<sstream>
 3 #include<fstream>
 4 #include<algorithm>
 5 #include<cstring>
 6 #include<iomanip>
 7 #include<cstdlib>
 8 #include<cctype>
 9 #include<vector>
10 #include<string>
11 #include<cmath>
12 #include<ctime>
13 #include<stack>
14 #include<queue>
15 #include<map>
16 #include<set>
17 #define mem(a,b) memset(a,b,sizeof(a))
18 #define random(a,b) (rand()%(b-a+1)+a)
19 #define ll long long
20 #define ull unsigned long long
21 #define e 2.71828182
22 #define Pi acos(-1.0)
23 #define ls(rt) (rt<<1)
24 #define rs(rt) (rt<<1|1)
25 #define lowbit(x) (x&(-x))
26 using namespace std;
27 const int MAXN=1e6+5;
28 int a[MAXN],sum[MAXN];
29 ll read()
30 {
31     ll s=1,x=0;
32     char ch=getchar();
33     while(!isdigit(ch)) {if(ch=='-') s=-1;ch=getchar();}
34     while(isdigit(ch)) {x=10*x+ch-'0';ch=getchar();}
35     return x*s;
36 }
37 int main()
38 {
39 //    a[1]=1;sum[1]=1;
40 //    for(int i=2;i<=100;++i)
41 //    {
42 //        a[i]=sum[i-1]%i;
43 //        sum[i]=sum[i-1]+i*a[i];
44 //    }
45 //    for(int i=1;i<=100;++i)
46 //    cout<<"i: "<<i<<" a[i]: "<<a[i]<<endl;
47     int test=read();
48     ll ans;
49     while(test--)
50     {
51         ll n=read();
52         ll tmp=(n+1)>>1;
53         if(n%2==0)
54         {
55             if(n%6==4)
56                 ans=tmp+tmp-1;
57             else ans=tmp;
58         }
59         else 
60         {
61             if(n%6==1)
62                 ans=tmp+n/6;
63             else ans=n/6;
64         }
65         cout<<ans<<"\n";
66     }
67     return 0;
68 }
View Code

 

 剩下的等题解再补

 

Guess you like

Origin www.cnblogs.com/wangzhebufangqi/p/11370526.html