UVA Problem 10880 Solution

Problem Solving, UVa

#include <iostream>

#include <algorithm>

#include <set>

#include <cmath>

using namespace std;



int main(void) {

  int tc, c, r,t,q;

  set<int> v;

    set<int>::iterator it;

  cin >> tc;



  for (t = 0; t < tc; t++) {

    cin >> c >> r;



    v.clear();



    cout << "Case #" << t+1 << ":";



    if (c == r) {

      cout << " 0" << endl;

      continue;

    }



    q = c - r;



    for (int i = 1; i <= sqrt(q); i++) {

      if (q % i == 0) {

        if (i > r)

          v.insert(i);



        if (q / i > r)

          v.insert(q/i);

      }

    }



    for ( it = v.begin(); it != v.end(); it++)

      cout << " " << *it;

    cout << endl;

  }



  return 0;

}

 

0 Comments

You may find interest following article

Complete Guide: Create Laravel Project in Docker Without Local Dependencies

Create Laravel Project Through Docker — No Need to Install PHP, MySQL, or Apache on Your Local Machine In this tutorial, I’ll show you how to create and run a full Laravel project using Docker containers. That means you won’t have to install PHP, MySQL, or Apache locally on your computer. By the end of this guide, you’ll have a fully functional Laravel development...