#include "stdio.h" int main(){ int num,i1,i2,i3,i4,i5,n; int n1,n2,n3,n4,n5; while(~scanf("%d",&num)){ n1=num/50; n2=num/25; n3=num/10; n4=num/5; n5=num; n=0; for(i1=0;i1<=n1;i1++){ for(i2=0;i2<=n2;i2++){ for(i3=0;i3<=n3;i3++){ for(i4=0;i4<=n4;i4++){ for(i5=0;i5<=n5;i5++){ if(i1*50+i2*25+i3*10+i4*5+i5==num && (i1+i2+i3+i4+i5)<=100){ n++;break; } } } } } } printf("%d\n",n); } return 0; }
ps:用了五个for,,暴力破解..差点就超出时间,还是用的G++过了...
代码:
时间: 2024-10-24 14:01:50