fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int n;
  5. scanf("%d",&n);
  6. for (int a=0;a<=9;a++) {
  7. for (int b =0;b<=9;b++) {
  8. for (int c=0;c<=9;c++) {
  9. int m=(a-b)*c+c;
  10. if (m==n) {
  11. printf("(%d-%d)*%d+%d\n",a,b,c,c);
  12. }
  13. }
  14. }
  15. }
  16. return 0;
  17. }
  18.  
  19.  
Success #stdin #stdout 0s 5216KB
stdin
8
stdout
(0-0)*8+8
(1-0)*4+4
(1-1)*8+8
(2-1)*4+4
(2-2)*8+8
(3-0)*2+2
(3-2)*4+4
(3-3)*8+8
(4-1)*2+2
(4-3)*4+4
(4-4)*8+8
(5-2)*2+2
(5-4)*4+4
(5-5)*8+8
(6-3)*2+2
(6-5)*4+4
(6-6)*8+8
(7-0)*1+1
(7-4)*2+2
(7-6)*4+4
(7-7)*8+8
(8-1)*1+1
(8-5)*2+2
(8-7)*4+4
(8-8)*8+8
(9-2)*1+1
(9-6)*2+2
(9-8)*4+4
(9-9)*8+8