Submission #66764
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #include <bits/stdc++.h> using namespace std; // clang-format off #define range(i, l, r) for ( int i = (int)(l); i < (int)(r); (i) += 1 ) #define rrange(i, l, r) for ( int i = (int)(r)-1; i >= (int)(l); (i) -= 1 ) #define debug(x) cerr << "(" << __LINE__ << ") " << #x << ": " << (x) << endl; template < typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true ); } template < typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true ); } template < typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << p.first << ' ' << p.second; return os; } template < typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &v) { for ( pair<T1, T2> x : v ) { os << x << "\n" ; } return os; } template < typename T> ostream &operator<<(ostream &os, queue<T> v) { if (!v.empty()) { os << v.front(); v.pop(); } while (!v.empty()) { os << " " << v.front(); v.pop(); } return os; } template < typename T> ostream &operator<<(ostream &os, stack<T> v) { if (!v.empty()) { os << v.top(); v.pop(); } while (!v.empty()) { os << " " << v.top(); v.pop(); } return os; } template < typename T> ostream &operator<<(ostream &os, const vector<T> &v) { bool is_f = true ; for ( T x : v ) { os << (is_f ? "" : " " ) << x; is_f = false ; } return os; } template < typename T> ostream &operator<<(ostream &os, const deque<T> &v) { bool is_f = true ; for ( T x : v ) { os << (is_f ? "" : " " ) << x; is_f = false ; } return os; } template < typename T> ostream &operator<<(ostream &os, const set<T> &v) { bool is_f = true ; for ( T x : v ) { os << (is_f ? "" : " " ) << x; is_f = false ; } return os; } using ull = unsigned long long ; using ll = long long ; using Pll = pair<ll, ll>; using P = pair< int , int >; constexpr ll INF64 = INT64_MAX / 2; constexpr int INF32 = INT32_MAX / 2; constexpr int dy[] = { 0, -1, 1, 0, -1, 1, -1, 1 }; constexpr int dx[] = { -1, 0, 0, 1, -1, -1, 1, 1 }; constexpr int mod998244353 = 998244353; constexpr int mod1000000007 = ( int )1e9 + 7; constexpr char newl = '\n' ; // clang-format on int main() { int n; cin >> n; bitset<10001> bit; bit.set(); for ( int i=2;i*i<=n;i++){ for ( int j=i+i;j<=n;j+=i){ bit[j]=0; } } range(i,2,n+1){ if (bit[i]) cout<<i<<newl; } } |
ステータス
項目 | データ |
---|---|
問題 | 1161 - プトレマイオスのざる |
ユーザー名 | matumoto |
投稿日時 | 2021-05-18 18:00:51 |
言語 | C++17 |
状態 | Accepted |
得点 | 1 |
ソースコード長 | 2328 Byte |
最大実行時間 | 29 ms |
最大メモリ使用量 | 600 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 1 / 1 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in1 | AC | 27 ms | 600 KB |
1
|
in2 | AC | 18 ms | 444 KB |
1
|
in3 | AC | 17 ms | 416 KB |
1
|
in4 | AC | 19 ms | 388 KB |
1
|
in5 | AC | 20 ms | 492 KB |
1
|
in6 | AC | 23 ms | 592 KB |
1
|
in7 | AC | 29 ms | 568 KB |
1
|