fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // your code goes here
  5. int a,b,c,e,p,q,r,n;
  6. scanf("%d",&n);
  7.  
  8. for(c=1 ;c<=9 ;c++){
  9. e=n%c;
  10. r=n-e;
  11. q=r/c;
  12. for(a=1 ;a<=9 ;a++){
  13. for(b=1 ;b<=9 ;b++)
  14. if(a-b==q)
  15. printf("(%d-%d)*%d+%d \n",a,b,c,e);
  16. }
  17. }
  18. return 0;
  19. }
  20.  
  21.  
Success #stdin #stdout 0.01s 5264KB
stdin
21
stdout
(8-1)*3+0 
(9-2)*3+0 
(6-1)*4+1 
(7-2)*4+1 
(8-3)*4+1 
(9-4)*4+1 
(5-1)*5+1 
(6-2)*5+1 
(7-3)*5+1 
(8-4)*5+1 
(9-5)*5+1 
(4-1)*6+3 
(5-2)*6+3 
(6-3)*6+3 
(7-4)*6+3 
(8-5)*6+3 
(9-6)*6+3 
(4-1)*7+0 
(5-2)*7+0 
(6-3)*7+0 
(7-4)*7+0 
(8-5)*7+0 
(9-6)*7+0 
(3-1)*8+5 
(4-2)*8+5 
(5-3)*8+5 
(6-4)*8+5 
(7-5)*8+5 
(8-6)*8+5 
(9-7)*8+5 
(3-1)*9+3 
(4-2)*9+3 
(5-3)*9+3 
(6-4)*9+3 
(7-5)*9+3 
(8-6)*9+3 
(9-7)*9+3