Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int t;
- cin >> t;
- while(t-- > 0) {
- int n;
- cin >> n;
- int ans = n - 1;
- for(int i = (int)sqrt(n); i >= 1; i--) {
- if(n % i == 0) {
- ans = n / i - i;
- break;
- }
- }
- cout << ans << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement