Free Contest 75 - FPRIME
View as PDF
Submit solution
Points:
0.06 (partial)
Time limit:
1.0s
Memory limit:
256M
Problem type
Allowed languages
C, C++, Go, Java, Kotlin, Pascal, PyPy, Python, Rust, Scratch
Comments
mấy bồ ơi sao mình sinh test 10e7 chạy 0,55s mà sao vẫn chạy TLE vậy:
include <bits/stdc++.h>
using namespace std; int n; vector<long long> a;
bool check (int x) { if(x == 2) return true; if(x < 2) return false; if(x % 2 == 0) return false;
} int main() { iosbase::syncwith_stdio(false); cin.tie(NULL); cin >> n; a.resize(n+1);
}
sàng đi ông
include <bits/stdc++.h>
using namespace std;
define ll long long
const ll N =1e7+1; ll a[N],n,l,r,snt[N],d[N],k; vector<ll> vec; int main(){ iosbase::syncwith_stdio(0); cin.tie(0); for(int i=1;i<=N;i++) snt[i]=1; snt[1]=0; for(int i=2;i<=sqrt(N);i++) if(snt[i]==1){ for(int j=i*i;j<=N;j+=i) snt[j]=0; } cin>>k; while(k--){ cin>>n; if(snt[n]==1) cout<<"YES"<<"\n"; else cout<<"NO"<<"\n"; } return 0; }
bai duoi qua
Nếu như sàng nguyên tố mà dùng mảng kiểu bool hoặc long long thì nhớ dùng '\n' thay cho endl để không bị TLE nhé, còn dùng bitset như mảng thì khỏi cần!
anh qua dep trai
This comment is hidden due to too much negative feedback. Show it anyway.