题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=5138
反着来.
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include <queue> using namespace std; int main() { int a[5] = {1,2,4,7,15}; int n; while(scanf("%d",&n)!=EOF){ int ans[5]; int id = 0; while(id<5){ if(n-a[id]<=0) break; ans[id++] = n-a[id]; } for(int i=id-1;i>=1;i--){ printf("%d ",ans[i]); } printf("%d ",ans[0]); } return 0; }