Advertisement
GastonFontenla

CheckerCorrectitud

Nov 11th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <sstream>
  4. #include <fstream>
  5. #include "BigNumber.h"
  6.  
  7. using namespace std;
  8.  
  9. long long toLL(string s)
  10. {
  11.     stringstream ss;
  12.     ss << s;
  13.     long long n;
  14.     ss >> n;
  15.     return n;
  16. }
  17.  
  18. int main()
  19. {
  20.     ifstream casos("casosCorrectitud.txt");
  21.     int cant;
  22.     casos >> cant;
  23.  
  24.     int fallidos = 0;
  25.  
  26.     for(int i=0; i<cant; i++)
  27.     {
  28.         string a, b;
  29.         long long la, lb;
  30.         casos >> a >> b;
  31.  
  32.         BigNumber na(a);
  33.         BigNumber nb(b);
  34.  
  35.         la = toLL(a);
  36.         lb = toLL(b);
  37.  
  38.         BigNumber resBN = na*nb;
  39.         long long resLL = la*lb;
  40.  
  41.         if(toLL(resBN.toStr()) != resLL)
  42.         {
  43.             fallidos++;
  44.         }
  45.     }
  46.  
  47.     cout << "Fallidos: " << fallidos << endl;
  48.  
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement