Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. bool eof=false;
  9. const int _multiple=45,buff_size=0x8000;
  10. char buffer[buff_size];
  11. int index=0;
  12.  
  13. vector <int> sol{0, 1, 5, 2, 8, 3, 9, 2, 8, 7, 7, 8, 4, 7, 3, 8, 4, 1, 5, 4, 4, 5, 9, 6, 2, 7, 3, 6, 2, 1, 1, 2, 8, 1, 7, 2, 8, 5, 9, 8, 8, 9, 3, 0, 6, 1, 7, 0, 6, 5, 5, 6, 2, 5, 1, 6, 2, 9, 3, 2, 2, 3, 7, 4, 0, 5, 1, 4, 0, 9, 9, 0, 6, 9, 5, 0, 6, 3, 7, 6, 6, 7, 1, 8, 4, 9, 5, 8, 4, 3, 3, 4, 0, 3, 9, 4, 0, 7, 1, 0, 0};
  14.  
  15. class parser{
  16. public:
  17. parser() {}
  18. parser(const char *file_name){
  19. input_file.open(file_name);
  20. input_file.sync_with_stdio(false);
  21. cursor=0;
  22. input_file.read(buffer,SIZE);}
  23. inline parser &operator >>(int &n){
  24. int last,current;
  25. while(buffer[cursor]<'0' or buffer[cursor]>'9') inc();
  26. n=last=current=0;
  27. while('0'<=buffer[cursor] and buffer[cursor]<='9'){
  28. last=current;
  29. current=buffer[cursor]-'0';
  30. inc();
  31. }
  32. n=sol[last*10+current];
  33. return *this;}
  34. private:
  35. ifstream input_file;
  36. static const int SIZE=0x8000;
  37. char buffer[SIZE];
  38. int cursor=0;
  39. inline void inc(){
  40. if(++cursor==SIZE)
  41. cursor=0,input_file.read(buffer,SIZE);
  42. }
  43. };
  44.  
  45. parser f ("cifra.in");
  46. ofstream t ("cifra.out");
  47.  
  48. int main()
  49. {
  50. int n;
  51. cin>>n;
  52. for (int aux,i=0;i<n;++i){
  53. f>>aux;
  54. t<<aux<<endl;
  55. }
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement