結果
問題 |
No.1514 Squared Matching
|
ユーザー |
![]() |
提出日時 | 2022-06-05 02:55:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 496 ms / 4,000 ms |
コード長 | 2,179 bytes |
コンパイル時間 | 3,444 ms |
コンパイル使用メモリ | 177,180 KB |
最終ジャッジ日時 | 2025-01-29 18:19:26 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
#include<iostream> #include<vector> #include<iomanip> #include<algorithm> #include<numeric> #include<queue> #include<unordered_set> #include<set> #include<map> #include<cmath> using namespace std; #include<atcoder/all> using namespace atcoder; //{{{ #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") struct _MyInit{ _MyInit(){ std::cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20); }; }_myinit; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using ull = unsigned long long; using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>; using vs = vector<string>; using pii = pair<int,int>; using vpii = vector<pii>; using vvpii = vector<vpii>; using pll = pair<ll,ll>; using vpll = vector<pll>; using vvpll = vector<vpll>; template<typename T> using pqueue = priority_queue<T>; template<typename T> using pqueue_g = priority_queue<T,vector<T>,greater<T>>; #define endl ('\n') #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define UNIQ(v) (v).erase(unique((v).begin(),(v).end()),(v).end()) #define _overload4(_1,_2,_3,_4,name,...) name #define __REP(i,s,e,d) for(ll i=ll(s);i<ll(e);i+=(d)) #define _REP(i,s,e) for(ll i=ll(s);i<ll(e);i++) #define REP(i,n) _REP(i,0,n) #define rep(...) _overload4(__VA_ARGS__,__REP,_REP,REP,)(__VA_ARGS__) #define reps(i,n) _REP(i,1,n+1) #define __RREP(i,s,e,d) for(ll i=ll(s);i>=ll(e);i-=d) #define _RREP(i,s,e) for(ll i=ll(s);i>=ll(e);i--) #define RREP(i,n) _RREP(i,n-1,0) #define rrep(...) _overload4(__VA_ARGS__,__RREP,_RREP,RREP,)(__VA_ARGS__) #define rreps(i,n) _RREP(i,n,1) template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;} template<class T>inline bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;} //}}} int main(){ ll n; cin >> n; vector<bool> a(n,true); a[0] = false; for(ll i=2;i*i<=n;i++){ ll I = i*i; for(ll j=1;j*I<=n;j++){ a[j*I]=false; } } ll ans = 0; for(ll k=1;k<=n;k++){ if(a[k]){ ll b=sqrt(n/k); ans += b*b; } } cout << ans << endl; return 0; }