Đề bài:
Code:
#include <vector>
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
const int MAXn=30001, MAXm=1e6+1;
long long k, rs, dem;
vector<long long> c;
bool a[MAXm];
void era(){
memset(a, true, sizeof(a));
a[0]=a[1]=false;
for(int i=2; i<=floor(sqrt(MAXm)); i++)
if(a[i])
for(int j=2; j<=MAXm/i; j++)
a[i*j]=false;
}
long long power( int n){
long long sum=1;
for(int i=1; i<=n; i++)
sum*=10;
return sum;
}
long long conect(long long m, long long n){
long long digits=0, l=n;
while(n!=0){
n/=10;
digits++;
}
return m*power(digits)+l;
}
bool check(long long g){
if(g<2) return false;
if(g<4) return true;
if(g%2==0 || g%3==0) return false;
for(int i=5; i<=floor(sqrt(g)); i+=6)
if(g%i==0 || g%(i+2)==0) return false;
return true;
}
int main(){
freopen("mprime.inp", "r", stdin);
freopen("mprime.out", "w", stdout);
cin >> k;
era();
for(int i=2; i<=MAXm; i++)
if(a[i]) c.push_back(i);
for(int i=0; i<=MAXn; i+=2){
rs=conect(c[i], c[i+1]);
if(check(rs)){
dem++;
if(dem==k){
cout << rs;
break;
}
}
}
return 0;
}
chạy bằng tay bình thường, nhưng chạy trong themis bị lỗi;-;
■ mprime:
● MPRIME: 0.00
MPRIME.cpp
"C:\Program Files (x86)\Themis\gcc\bin\g++.exe" -std=c++14 "MPRIME.cpp" -pipe -O2 -s -static -lm -x c++ -o"MPRIME.exe" -Wl,--stack,66060288|@WorkDir=C:\ProgramData\ThemisWorkSpace\WaitRoom11669\
Dịch thành công.
◆ Test01: 0.00
Chạy sinh lỗi
Command: "C:\ProgramData\ThemisWorkSpace\ContestRoom4524\MPRIME.exe" terminated with exit code: 3221225477 (Hexadecimal: C0000005)
◆ Test02: 0.00
Chạy sinh lỗi
Command: "C:\ProgramData\ThemisWorkSpace\ContestRoom65256\MPRIME.exe" terminated with exit code: 3221225477 (Hexadecimal: C0000005)
◆ Test03: 0.00
Chạy sinh lỗi
Command: "C:\ProgramData\ThemisWorkSpace\ContestRoom26655\MPRIME.exe" terminated with exit code: 3221225477 (Hexadecimal: C0000005)
◆ Test04: 0.00
Chạy sinh lỗi
Command: "C:\ProgramData\ThemisWorkSpace\ContestRoom45197\MPRIME.exe" terminated with exit code: 3221225477 (Hexadecimal: C0000005)
◆ Test05: 0.00
Chạy sinh lỗi
Command: "C:\ProgramData\ThemisWorkSpace\ContestRoom13095\MPRIME.exe" terminated with exit code: 3221225477 (Hexadecimal: C0000005)
◆ Test06: 0.00
Chạy sinh lỗi
Command: "C:\ProgramData\ThemisWorkSpace\ContestRoom16696\MPRIME.exe" terminated with exit code: 3221225477 (Hexadecimal: C0000005)
◆ Test07: 0.00
Chạy sinh lỗi
Command: "C:\ProgramData\ThemisWorkSpace\ContestRoom28396\MPRIME.exe" terminated with exit code: 3221225477 (Hexadecimal: C0000005)
◆ Test08: 0.00
Chạy sinh lỗi
Command: "C:\ProgramData\ThemisWorkSpace\ContestRoom675\MPRIME.exe" terminated with exit code: 3221225477 (Hexadecimal: C0000005)
◆ Test09: 0.00
Chạy sinh lỗi
Command: "C:\ProgramData\ThemisWorkSpace\ContestRoom25783\MPRIME.exe" terminated with exit code: 3221225477 (Hexadecimal: C0000005)
◆ Test10: 0.00
Chạy sinh lỗi
Command: "C:\ProgramData\ThemisWorkSpace\ContestRoom28276\MPRIME.exe" terminated with exit code: 3221225477 (Hexadecimal: C0000005)
◆ Test11: 0.00
Chạy sinh lỗi
Command: "C:\ProgramData\ThemisWorkSpace\ContestRoom42232\MPRIME.exe" terminated with exit code: 3221225477 (Hexadecimal: C0000005)
◆ Test12: 0.00
Chạy sinh lỗi
Command: "C:\ProgramData\ThemisWorkSpace\ContestRoom8174\MPRIME.exe" terminated with exit code: 3221225477 (Hexadecimal: C0000005)
◆ Test13: 0.00
Chạy sinh lỗi
Command: "C:\ProgramData\ThemisWorkSpace\ContestRoom23872\MPRIME.exe" terminated with exit code: 3221225477 (Hexadecimal: C0000005)
◆ Test14: 0.00
Chạy sinh lỗi
Command: "C:\ProgramData\ThemisWorkSpace\ContestRoom52544\MPRIME.exe" terminated with exit code: 3221225477 (Hexadecimal: C0000005)
◆ Test15: 0.00
Chạy sinh lỗi
Command: "C:\ProgramData\ThemisWorkSpace\ContestRoom45146\MPRIME.exe" terminated with exit code: 3221225477 (Hexadecimal: C0000005)
em bị sai ở đâu vậy ạ, em cảm ơn <3