290 230 280 200 300 170 340 50 90 80 200 60
-7
#include <cstdio> #include <iostream> #include <string> #include <cstring> #include <algorithm> #include <queue> using namespace std; int main() { int storage[18], month = 0, i; int sum = 0, s = 0; for(i = 0; i<12; i++) { scanf("%d", &storage[i]); } for(i = 0; i<12; i++) { sum += (300-storage[i]); // printf("i = %d, sum = %d\n", i, sum); if(sum > 0) while(sum) { if(sum >= 100) { sum -= 100; // printf("sum = %d, ",sum); s += 100; // printf("s = %d\n", s); if(sum == 0)month++; } else if(sum<100 && sum >= 0) { month++; break; } } else if(sum == 0)month++; else if(sum<0) { printf("-%d\n", ++month); break; } } if(i == 12) { s = s+s*0.2+sum; printf("%d\n", s); } return 0; }
原文:https://www.cnblogs.com/RootVount/p/10432879.html