题解 | #Old Bill#
Old Bill
https://www.nowcoder.com/practice/17a30153e092493e8b4d13f321343927
#include <stdio.h> #include <stdlib.h> int main() { int N; int x,y,z; scanf("%d",&N); scanf("%d %d %d",&x,&y,&z); int value=0,curr=0; int fadedFore=-1,fadedLast=-1; for(int maxPos=1;maxPos<10;maxPos++){ for(int minPos=0;minPos<10;minPos++){ int price=maxPos*10000+x*1000+y*100+z*10+minPos; if (price%N==0){ curr=price/N; if (curr>value){ value=curr; fadedFore=maxPos; fadedLast=minPos; } } } } if(fadedFore==-1||fadedLast==-1){ printf("0\n"); return 0; } printf("%d %d %d",fadedFore,fadedLast,value); }