计蒜客 UCF 2015

#A.Find the twins

# 题意

# 题解

``` 1 #include<bits/stdc++.h>
2 #define ll long long
3 using namespace std;
4 const int N=2e5+10;
5 int a[15];
6 int n;
7 int main(){
8     n=10;
9     int t;
10     cin>>t;
11
12     for(int k=1;k<=t;k++){
13         bool z=0,m=0;
14         for(int i=1;i<=n;i++){
15             cin>>a[i];
16             if(a[i]==18)
17                 m=1;
18             if(a[i]==17)
19                 z=1;
20         }
21
22         for(int i=1;i<=n;i++) {
23             if(i!=n)
24               printf("%d ",a[i]);
25             else
26                 printf("%d",a[i]);
27         }
28         puts("");
29         if(m&&z) {
30                 puts("both");
31         }
32         else if(m) {
33             puts("mack");
34             }
35         else if(z) {
36                 puts("zack");
37         }
38         else {
39                 puts("none");
40         }
41         puts("");
42     }
43
44 }```

#B.Medal Ranking

#题解

``` 1 #include<bits/stdc++.h>
2 #define ll long long
3 using namespace std;
4 const int N=2e5+10;
5 int a[15];
6 int n;
7 int main(){
8     n=10;
9     int t;
10     cin>>t;
11
12     for(int k=1;k<=t;k++){
13         bool cnt=0,col=0;
14         int m1,m2,m3;
15         int r1,r2,r3;
16         cin>>m1>>m2>>m3;
17         cin>>r1>>r2>>r3;
18         int summ=m1+m2+m3;
19         int sumr=r1+r2+r3;
20         if(summ>sumr)
21             cnt=1;
22
23         if(m1 > r1)
24             col=1;
25         if(m1 == r1){
26             if(m2>r2)
27                 col=1;
28             if(m2==r2){
29                 if(m3>r3)
30                     col=1;
31             }
32         }
33
34         cout<<m1<<‘ ‘<<m2<<‘ ‘<<m3<<‘ ‘<<r1<<‘ ‘<<r2<<‘ ‘<<r3<<endl;
35         if(col && cnt)
36             cout<<"both"<<endl;
37         else if(cnt)
38             cout<<"count"<<endl;
39         else if(col)
40             cout<<"color"<<endl;
41
42         else cout<<"none"<<endl;
43         puts("");
44     }
45
46 }```

# 题解

``` 1 #include<bits/stdc++.h>
2 #define ll long long
3 using namespace std;
4 const int N=2e5+10;
5 int main(){
6     int t;
7     cin>>t;
8     for(int i=1;i<=t;i++){
9         int n,cnt;
10         cin>>n>>cnt;
11         printf("Practice #%d: %d %d\n",i,n,cnt);
12         int m;
13         cin>>m;
14         for(int j=1;j<=m;j++){
15             int x;
16             cin>>x;
17             while(x>=cnt)
18                 cnt*=2;
19             cnt-=x;
20             cout<<x<<‘ ‘<<cnt<<endl;
21         }
22         puts("");
23     }
24
25 }```

# 题意

# 题解

``` 1 #include <bits/stdc++.h>
2 #define ll long long
3 using namespace std;
4 struct node{
5     ll cnt,pl,ps;
6 }day[1010];
7 void work(){
8     ll d,x,y;
9     cin>>d>>x>>y;
10     day[0].pl=INT_MAX;
11     day[0].ps=INT_MAX;
12     for(int i=1;i<=d;i++){
13         cin>>day[i].cnt>>day[i].pl>>day[i].ps;
14         day[i].pl=min(day[i].pl,day[i-1].pl);
15         day[i].ps=min(day[i].ps,day[i-1].ps);
16     }
17
18     ll ans=0,now_r=0;
19     for(int i=1;i<=d;i++){
20
21         ans+=day[i].cnt*x*day[i].pl;
22         now_r-=day[i].cnt * y;
23         while(now_r<0){
24             now_r+=80;
25             ans+=day[i].ps;
26         }
27         //ll need=day[i].cnt*y;
28         //need-=now_r;
29
30         /*if(need > 80 && need % 80){
31             now_r = (need/80+1)*80 - need;
32             ans+=(need / 80 +1) * day[i].ps;
33         }
34         else if(need > 80 && !(need % 80)){
35             now_r= 0;
36             ans+=need/80 * day[i].ps;
37         }
38         else if(need<80){
39             now_r=80-need;
40             ans+=day[i].ps;
41         }
42          */
43
44     }
45     cout<<ans<<endl;
46 }
47 int main(){
48     int t;
49     cin>>t;
50     while(t--){
51         work();
52     }
53 }```

# E.Rain Gauge

# 题意

即给定一个正方形和圆，求圆覆盖正方形的面积

``` 1 #include<bits/stdc++.h>
2 #define ll long long
3 using namespace std;
4 const double pi=3.14159265358979;
5 int main(){
6     int t;
7     cin>>t;
8     for(int i=1;i<=t;i++){
9         double s,r;
10         cin>>s>>r;
11         double d=s/2;
12         double p=sqrt(2)*d;
13         double ans;
14         if(r>=p) {
15             ans = s*s;
16         }
17         else if(r<=d)
18             ans=pi*r*r;
19         else if(r<p && r>d){
20             double c= sqrt(r*r-d*d);
21             double rec=c*d;
22             double jd=2*acos(d/r);
23             double cir=jd*r*r/2;
24             double la=cir-rec;
25             ans = pi*r*r-4*la;
26         }
27         cout<<fixed<<setprecision(2)<<ans<<endl;
28     }
29
30 }```

G.Towers of Hanoi grid

# 题意

n*n的网格，从（1，1）中的d个从上到下递减的塔移动到（n，n）点上去，

# 题解

``` 1 #include<iostream>
2 #include<cstring>
3 #include<cstdio>
4 using namespace std;
5 int main(){
6     int t;
7     cin>>t;
8     for(int i=1;i<=t;i++){
9         int d,n;
10         cin>>d>>n;
11         if(d > (n-1)*(n-1)+1)
12             cout<<"Grid #"<<i<<": "<<"impossible"<<endl;
13         else
14             cout<<"Grid #"<<i<<": "<<d*(n-1)*2<<endl;
15         puts("");
16     }
17     return 0;
18
19 }```

(0)
(0)