计蒜客 UCF 2015
阅读原文时间:2023年07月10日阅读:1

# A.Find the twins

# 题意

找出每个序列是否有特定的值

# 题解

坑,原始序列输出的时候每一行最后一个不能有空格

#include
#define ll long long
using namespace std;
const int N=2e5+;
int a[];
int n;
int main(){
n=;
int t;
cin>>t;

 for(int k=;k<=t;k++){  
     bool z=,m=;  
     for(int i=;i<=n;i++){  
         cin>>a\[i\];  
         if(a\[i\]==)  
             m=;  
         if(a\[i\]==)  
             z=;  
     }

     for(int i=;i<=n;i++) {  
         if(i!=n)  
           printf("%d ",a\[i\]);  
         else  
             printf("%d",a\[i\]);  
     }  
     puts("");  
     if(m&&z) {  
             puts("both");  
     }  
     else if(m) {  
         puts("mack");  
         }  
     else if(z) {  
             puts("zack");  
     }  
     else {  
             puts("none");  
     }  
     puts("");  
 }

}

# B.Medal Ranking 

# 题解

水题一样还是最后一行空格

#include
#define ll long long
using namespace std;
const int N=2e5+;
int a[];
int n;
int main(){
n=;
int t;
cin>>t;

 for(int k=;k<=t;k++){  
     bool cnt=,col=;  
     int m1,m2,m3;  
     int r1,r2,r3;  
     cin>>m1>>m2>>m3;  
     cin>>r1>>r2>>r3;  
     int summ=m1+m2+m3;  
     int sumr=r1+r2+r3;  
     if(summ>sumr)  
         cnt=;

     if(m1 > r1)  
         col=;  
     if(m1 == r1){  
         if(m2>r2)  
             col=;  
         if(m2==r2){  
             if(m3>r3)  
                 col=;  
         }  
     }

     cout<<m1<<' '<<m2<<' '<<m3<<' '<<r1<<' '<<r2<<' '<<r3<<endl;  
     if(col && cnt)  
         cout<<"both"<<endl;  
     else if(cnt)  
         cout<<"count"<<endl;  
     else if(col)  
         cout<<"color"<<endl;

     else cout<<"none"<<endl;  
     puts("");  
 }

}

# C. Cookies

# 题解

饼干不够就切

#include
#define ll long long
using namespace std;
const int N=2e5+;
int main(){
int t;
cin>>t;
for(int i=;i<=t;i++){ int n,cnt; cin>>n>>cnt;
printf("Practice #%d: %d %d\n",i,n,cnt);
int m;
cin>>m;
for(int j=;j<=m;j++){ int x; cin>>x;
while(x>=cnt)
cnt*=;
cnt-=x;
cout<<x<<' '<<cnt<<endl;
}
puts("");
}

}

# D. Lemonade Stand

# 题意

一个柠檬水店,每一杯柠檬水的制作需要糖和柠檬,知道每天都会来多少人,每天柠檬和糖的原材料价格都不一样,

每天可以买任意多的和任意少的,每天的所有客人都要被满足,每天的价格是单个柠檬的价格和80 盎司糖的价格,剩下的原料第二天可以使用。

# 题解

从前往后只记录之前的价格的最小值即可,因为糖只能一包一包买也就是80盎司,

第二天可以使用第一天剩余的,并且只能第二天使用,剩余的一定小于80盎司。

#include
#define ll long long
using namespace std;
struct node{
ll cnt,pl,ps;
}day[];
void work(){
ll d,x,y;
cin>>d>>x>>y;
day[].pl=INT_MAX;
day[].ps=INT_MAX;
for(int i=;i<=d;i++){ cin>>day[i].cnt>>day[i].pl>>day[i].ps;
day[i].pl=min(day[i].pl,day[i-].pl);
day[i].ps=min(day[i].ps,day[i-].ps);
}

 ll ans=,now\_r=;  
 for(int i=;i<=d;i++){

     ans+=day\[i\].cnt\*x\*day\[i\].pl;  
     now\_r-=day\[i\].cnt \* y;  
     while(now\_r<){  
         now\_r+=;  
         ans+=day\[i\].ps;  
     }  
     //ll need=day\[i\].cnt\*y;  
     //need-=now\_r;

     /\*if(need > 80 && need % 80){  
         now\_r = (need/80+1)\*80 - need;  
         ans+=(need / 80 +1) \* day\[i\].ps;  
     }  
     else if(need > 80 && !(need % 80)){  
         now\_r= 0;  
         ans+=need/80 \* day\[i\].ps;  
     }  
     else if(need<80){  
         now\_r=80-need;  
         ans+=day\[i\].ps;  
     }  
      \*/

 }  
 cout<<ans<<endl;  

}
int main(){
int t;
cin>>t;
while(t--){
work();
}

# E.Rain Gauge

# 题意

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

# 题解

分成三种情况,两种正好的情况直接计算,另一种求出来出来的面积,圆的面积减去即可

利用反三角函数,反三角函数返回的是弧度制

#include
#define ll long long
using namespace std;
const double pi=3.14159265358979;
int main(){
int t;
cin>>t;
for(int i=;i<=t;i++){ double s,r; cin>>s>>r;
double d=s/;
double p=sqrt()*d;
double ans;
if(r>=p) {
ans = s*s;
}
else if(r<=d) ans=pi*r*r; else if(r

d){
double c= sqrt(r*r-d*d);
double rec=c*d;
double jd=*acos(d/r);
double cir=jd*r*r/;
double la=cir-rec;
ans = pi*r*r-*la;
}
cout<<fixed<<setprecision()<<ans<<endl;
}

}

# G.Towers of Hanoi grid 

# 题意

n*n的网格,从(1,1)中的d个从上到下递减的塔移动到(n,n)点上去,

除了(1,1)和(n,n)以外其余的点只能放一个塔,如果能移动求最少的移动次数,如果不行输出impossible

# 题解

画图易知必须有一条可行的哈密顿路径供最下面的塔移动到(n,n)

#include
#include
#include
using namespace std;
int main(){
int t;
cin>>t;
for(int i=;i<=t;i++){ int d,n; cin>>d>>n;
if(d > (n-)*(n-)+)
cout<<"Grid #"<<i<<": "<<"impossible"<<endl;
else
cout<<"Grid #"<<i<<": "<<d*(n-)*<<endl;
puts("");
}
return ;

}

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章