fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main ()
  5. {
  6. while (1)
  7. {
  8. string Num;
  9. cin>>Num;
  10. if (Num=="0") break;
  11. long long S=0;
  12. for (int i=0; i<Num.length(); i++)
  13. {
  14. int so=Num[i]-'0';
  15. if (so>4) so--;
  16. S=S*9+so;
  17. }
  18. cout<<Num<<": "<<S<<endl;
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0s 15240KB
stdin
13 
15 
2003 
2005 
239 
250 
1399 
1500 
999999
999999999
0
stdout
13: 12
15: 13
2003: 1461
2005: 1462
239: 197
250: 198
1399: 1052
1500: 1053
999999: 531440
999999999: 387420488