| Task: | Alien Invasion II |
| Sender: | Naila |
| Submission time: | 2020-09-19 14:10:15 +0300 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | TIME LIMIT EXCEEDED |
| test | verdict | time | |
|---|---|---|---|
| #1 | TIME LIMIT EXCEEDED | -- | details |
| #2 | WRONG ANSWER | 0.01 s | details |
| #3 | WRONG ANSWER | 0.01 s | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:35:7: warning: unused variable 'a' [-Wunused-variable]
bool a,b=1;
^Code
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
bool Prime(long long n)
{
bool prime = 1;
for (int i = 2; i * i <= n && (n % i || (prime = 0)); i++);
return prime;
}
void Factors(long long n)
{
int cnt = 0;
long long i;
for (i = 2; i <= sqrt(n) && cnt<1; i++)
{
if (n % i == 0)
{
cout << i << " ";
cnt++;
}
}
cout << (n/(i-1))<<endl;
}
int main()
{
long long n,n1;
string s,s1;
bool a,b=1;
cin >> n;
n1 = n;
/*a = Prime(n);
if (a == 0)
{
cout << n << endl;
Factors(n);
}*/
long long i = 1;
b = Prime(n1);
while (b == 1)
{
s = to_string(n);
s1 = to_string(i);
s = s1 + s;
n1 = stoi(s);
b = Prime(n1);
i++;
}
cout << n1 << endl;
Factors(n1);
}Test details
Test 1
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 2368469234876449 |
| correct output |
|---|
| 22368469234876449 3 7456156411625483 |
| user output |
|---|
| (empty) |
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 292929292929292929292929292931 |
| correct output |
|---|
| 129292929292929292929292929293... |
| user output |
|---|
| 9223372036854775807 7 1317624576693539401 |
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 292929292929292929292929292979 |
| correct output |
|---|
| 129292929292929292929292929297... |
| user output |
|---|
| 9223372036854775807 7 1317624576693539401 |
