7月1日 cf总结

7月1日  cf总结

A题:水题,题意看半天,30分钟才A。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<math.h>
#include<cctype>
#define ll long long
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define REPP(i,a,b,t) for(int (i)=(a);(i)<=(b);(i)+=(t))
#define rep(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define repp(i,a,b,t) for(int (i)=(a);(i)>=(b);(i)-=(t))
#define PII pair<int,int>
#define fst first
#define snd second
#define MP make_pair
#define PB push_back
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define DRI(x) int (x);scanf("%d",&(x))
#define DRII(x,y) int (x),(y);scanf("%d%d",&(x),&(y))
#define DRIII(x,y,z) int (x),(y),(z);scanf("%d%d",&(x),&(y),&(z))
#define RS(x) scanf("%s",x)
#define RSS(x,y) scanf("%s%s",x,y)
#define DRS(x) char x[maxn];scanf("%s",x)
#define DRSS(x,y) char x[maxn],y[maxn];scanf("%s%s",x,y)
#define MS0(a) memset((a),0,sizeof((a)))
#define MS1(a) memset((a),-1,sizeof((a)))
#define MS(a,b) memset((a),(b),sizeof((a)))
#define ALL(v) v.begin(),v.end()
#define SZ(v) (int)(v).size()

using namespace std;

const int maxn=1000100;
const int INF=(1<<29);
const double EPS=0.0000000001;
const double Pi=acos(-1.0);

int a[10],b[10];
int n;
int c[10];

int main()
{
    while(cin>>n){
        REP(i,1,3) RI(a[i]),RI(b[i]);
        int ans=a[1]+a[2]+a[3];
        REP(i,1,3) c[i]=a[i];
        REP(i,1,3){
            if(ans==n) break;
            REP(j,1,b[i]-a[i]){
                ans++;
                c[i]++;
                if(ans==n) break;
            }
        }
        cout<<c[1]<<" "<<c[2]<<" "<<c[3]<<endl;
    }
    return 0;
}
View Code

B题:水题,题意还是看半天,坑的是cout输出浮点数在第32个样例WA了,该printf就过了。。。。。看来以后浮点数都用printf输出。。。

由于cout对浮点数只保留到小数点后6位,而printf可以保留的位数更多,且可以根据需要确定进度,看来以后浮点数直接printf就好了。。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<math.h>
#include<cctype>
#define ll long long
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define REPP(i,a,b,t) for(int (i)=(a);(i)<=(b);(i)+=(t))
#define rep(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define repp(i,a,b,t) for(int (i)=(a);(i)>=(b);(i)-=(t))
#define PII pair<int,int>
#define fst first
#define snd second
#define MP make_pair
#define PB push_back
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define DRI(x) int (x);scanf("%d",&(x))
#define DRII(x,y) int (x),(y);scanf("%d%d",&(x),&(y))
#define DRIII(x,y,z) int (x),(y),(z);scanf("%d%d",&(x),&(y),&(z))
#define RS(x) scanf("%s",x)
#define RSS(x,y) scanf("%s%s",x,y)
#define DRS(x) char x[maxn];scanf("%s",x)
#define DRSS(x,y) char x[maxn],y[maxn];scanf("%s%s",x,y)
#define MS0(a) memset((a),0,sizeof((a)))
#define MS1(a) memset((a),-1,sizeof((a)))
#define MS(a,b) memset((a),(b),sizeof((a)))
#define ALL(v) v.begin(),v.end()
#define SZ(v) (int)(v).size()

using namespace std;

const int maxn=1000100;
const int INF=(1<<29);
const double EPS=0.0000000001;
const double Pi=acos(-1.0);

double c[maxn];
int n;
double w;

int main()
{
    while(cin>>n>>w){
        REP(i,1,2*n) scanf("%lf",&c[i]);
        sort(c+1,c+1+2*n);
        double a=c[1],b=c[n+1];
        double ans=0;
        if(a*2<b){
            ans=a*n+a*2*n;
            if(ans<w) printf("%f\n",ans);
            else printf("%f\n",w);
        }
        else{
            ans=b*n/2.0+b*n;
            if(ans<w) printf("%f\n",ans);
            else printf("%f\n",w);
        }
    }
    return 0;
}
View Code

 

posted @ 2015-07-01 01:54  __560  阅读(338)  评论(0编辑  收藏  举报