Codeforces Round #130 (Div. 2)

来源:互联网 发布:博库数据库 编辑:程序博客网 时间:2024/05/11 02:59

A. Dubstep


#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#define LL long long#define N 1000000using namespace std;char str[205];bool check(int i){if(str[i]=='W'&&str[i+1]=='U'&&str[i+2]=='B')return true;    return false;}int main(){while(scanf("%s",str)!=EOF){bool word=false;for(int i=0;i<strlen(str);i++){if(!check(i)){if(word)printf(" ");for(;i<strlen(str);i++)if(check(i))break;elseprintf("%c",str[i]);i+=2;word=true;}elsei+=2;}cout<<endl;}return 0;}


D. Prizes, Prizes, more Prizes


#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#define LL long long#define N 1000000using namespace std;struct Node{int cost,idx;}a[5];int n;LL p[50];bool cmp(Node n1,Node n2){return n1.cost>n2.cost;}int main(){while(scanf("%d",&n)!=EOF){for(int i=0;i<n;i++)scanf("%I64d",&p[i]);LL sum=0;for(int i=0;i<5;i++){scanf("%d",&a[i].cost);a[i].idx=i;}sort(a,a+5,cmp);LL cnt[5];memset(cnt,0,sizeof(cnt));for(int i=0;i<n;i++){sum+=p[i];for(int j=0;j<5;j++){cnt[a[j].idx]+=sum/a[j].cost;sum%=a[j].cost;}}printf("%I64d %I64d %I64d %I64d %I64d\n%I64d\n",cnt[0],cnt[1],cnt[2],cnt[3],cnt[4],sum);}return 0;}



0 0
原创粉丝点击