結果
問題 |
No.1514 Squared Matching
|
ユーザー |
![]() |
提出日時 | 2025-07-07 12:25:11 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 629 ms / 4,000 ms |
コード長 | 1,081 bytes |
コンパイル時間 | 3,045 ms |
コンパイル使用メモリ | 276,672 KB |
実行使用メモリ | 52,472 KB |
最終ジャッジ日時 | 2025-07-07 12:25:27 |
合計ジャッジ時間 | 16,137 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
コンパイルメッセージ
main.cpp: In function ‘void sang()’: main.cpp:31:16: warning: iteration 50000004 invokes undefined behavior [-Waggressive-loop-optimizations] 31 | if(!s[i]){ | ~~~^ main.cpp:15:34: note: within this loop 15 | #define fo(i, a, b) for(ll i=a; i<=b; i++) | ^ main.cpp:30:5: note: in expansion of macro ‘fo’ 30 | fo(i, 1, maxn){ | ^~
ソースコード
/* #pragma GCC target("avx") #pragma GCC optimize("O2") #pragma GCC optimize("inline") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("no-stack-protector") */ #include <bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define fo(i, a, b) for(ll i=a; i<=b; i++) #define fod(i, a, b) for(ll i=a; i>=b; i--) #define lop(x, s) for(auto x : s) #define sz(s) s.size() #define all(s) s.begin(), s.end() #define pll pair<ll, ll> #define pb push_back #define mp make_pair const ll maxn=5e7+5; int n, f[7105]; ll res=0; bool s[maxn]; void sang(){ fo(i, 1, maxn){ if(!s[i]){ int j=2; while(f[j]*i<=maxn){ s[f[j]*i]=1; j++; } } } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; fo(i, 1, 7100){ f[i]=i*i; } sang(); fo(i, 1, n){ if(!s[i]){ ll a=sqrt(n/i); res+=f[a]; } } cout << res; return 0; }