A. Dubstep
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define LL long long
#define N 1000000
using 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;
else
printf("%c",str[i]);
i+=2;
word=true;
}
else
i+=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 1000000
using 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;
}