Problem Link
: https://www.spoj.com/problems/TRIALDIV/
I have doubt regarding my solution working fine or not.
I am unable to access all test cases of the above problem to understand my code fault and when i submit my solution code, it shows wrong answer.
I believe that my solution code is correct. if not please let me know. I just want my solution code fault that make it show wrong answer.
Hence please help me.
My C++11 code for above problem is as follows:
#include <bits/stdc++.h>
using namespace std;
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
unsigned int t;
unsigned long long num, i;
cin >> t;
while (t) {
cin >> num;
if (num==1) {
cout << "1" << endl;
t--;
continue;
}
i=2;
while (num > 1 and i <= num) {
if (i>(num/i))
i=num;
if (num%i==0) {
num = num/i;
cout << i << " ";
}
else
i++;
}
cout << endl;
t--;
}
return 0;
}
Thank you