Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
求教。。。以下代码G++ wa C++ac。。。。#include <iostream> #include <algorithm> #include <stdio.h> #include <string.h> using namespace std; struct DICE { int id; long long l,r; long long a; }dice[2000],*di[2000]; int n; bool cmp(DICE* a,DICE* b) { return a->a<b->a; } int main() { cin>>n; long long sum=0; memset(dice,0,sizeof(dice)); for (int i=0;i<n;++i) { dice[i].id=i; cin>>dice[i].a; sum+=dice[i].a; di[i]=&dice[i]; } sort(di,di+n,cmp); double E=0.0; for (int i=0;i<n;++i) { di[i]->r=sum; sum-=di[i]->a; di[i]->l=sum+1; E+=((double)(di[i]->r+di[i]->l))/2.0; } printf("%.5lf\n",E); for (int i=0;i<n;++i) { printf("%d",dice[i].l); for (int j=dice[i].l+1;j<=dice[i].r;++j) printf(" %d",j); printf("\n"); } //system("pause"); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator