Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- const char duom[] = "Duomenys.txt";
- const char rez[] = "Rezultatai.txt";
- int kiek_reikes_plyteliu(const int x, const int y, int sx, int sy) {
- int rez1, rez2;
- sx *= 100;
- sy *= 100;
- rez1 = (sx/x+(sx%x == 0 ? 0 : 1)) * (sy/y+(sy%y == 0 ? 0 : 1));
- rez2 = (sx/y+(sx%y == 0 ? 0 : 1)) * (sy/x+(sy%x == 0 ? 0 : 1));
- return rez1 > rez2 ? rez2 : rez1;
- }
- /* Dar vienas variantas:
- int kiek_reikes_plyteliu(int x, int y, int Sx, int Sy)
- {
- int Dx, Dy, Lx, Ly;
- Lx = Sx * 100 / x ;
- Ly = Sy * 100 / y ;
- Dx = (Sx * 100) % x;
- Dy = (Sy * 100) % y;
- if (Dx != 0)
- Lx++;
- if (Dy != 0)
- Ly++;
- return Lx * Ly;
- }
- */
- int main() {
- int x, y, sx, sy;
- ifstream in(duom);
- ofstream out(rez);
- while( in >> x >> y >> sx >> sy )
- out << kiek_reikes_plyteliu(x, y, sx, sy) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment