Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
prime factorization trial division
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#include<bits/stdc++.h> #define LL long long #define MAXN 1000000000 using namespace std; inline void speed(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } vector <bool> isprime(MAXN,1); vector <int> primes; inline void pre(){ for(int i=2;i*i<MAXN;i++){ if(isprime[i]){ primes.push_back(i); for(int j=i*i;j<MAXN;j+=i){ isprime[j]=0; } } } for(int i=2;i<MAXN;i++){ if(isprime[i]){ primes.push_back(i); } } } int main() { speed(); pre(); LL n; //cin>>n; //for(int i=0;i<100;i++)cout<<primes[i]<<" "; /*while ( n != 0 ) { for(int i=0;i<primes.size();i++){ int pw=0; //cout<<n<<" "<<primes[i]<<endl; while(n%primes[i]==0){ if(n==1)break; //cout<<n<<" "<<primes[i]<<endl; n=n/primes[i]; pw++; } if(pw>0){ cout<<primes[i]<<"^"<<pw<<" "; } if(n==1){ break; } } if(n!=1){ cout<<n<<"^"<<1; } cout<<"\n"; cin>>n; }*/ return 0; }
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
edit mode
|
history
|
discussion