static int buyCoke(int m, int a, int b, int c, int x) { int ans =0; while (m>0){ m--; int count = 0; while(count<x&&c>0){ count +=100; c--; ans++; } while(count<x&&b>0){ count +=50; b--; ans++; } while(count<x&&a>0){ count +=10; a--; ans++; } b+=(count-x)/50; a+=((count-x)%50)/10; } return ans; } 只过了50,目测就是没考虑“钱不够”