card
#include<stdio.h> #include<stdlib.h> int book[25]; int ans; int test(int data[999]){ for(int i=0;i<999;i++) book[data[i]]++; for(int i=12;i>=1;i--) { while(book[i]>=2&&book[2*i]>=1) { book[i]=book[i]-2; book[2*i]--; } } for(int i=1;i<=24;i++) { ans=ans+i*book[i]; } return ans; } void build(int data[999]){ for(int i=0;i<999;i++) data[i]=rand()%24+1; } void main(){ int data[999]; for(int l=0;l<10;l++){ for(int i=1;i<=24;i++) book[i]=0; ans=0; build(data); printf("%d\n",test(data)); } }