結果

問題 No.1514 Squared Matching
ユーザー abc3abc3
提出日時 2022-06-05 04:56:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,747 ms / 4,000 ms
コード長 1,298 bytes
コンパイル時間 2,327 ms
コンパイル使用メモリ 203,908 KB
実行使用メモリ 393,892 KB
最終ジャッジ日時 2023-10-21 03:03:24
合計ジャッジ時間 32,674 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1,730 ms
393,892 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 30 ms
9,184 KB
testcase_07 AC 337 ms
77,956 KB
testcase_08 AC 1,662 ms
379,656 KB
testcase_09 AC 1,458 ms
332,332 KB
testcase_10 AC 1,617 ms
359,788 KB
testcase_11 AC 1,639 ms
374,640 KB
testcase_12 AC 1,685 ms
385,124 KB
testcase_13 AC 1,715 ms
390,148 KB
testcase_14 AC 1,720 ms
392,244 KB
testcase_15 AC 1,727 ms
393,052 KB
testcase_16 AC 1,729 ms
393,564 KB
testcase_17 AC 1,747 ms
393,760 KB
testcase_18 AC 1,725 ms
393,844 KB
testcase_19 AC 1,717 ms
393,844 KB
testcase_20 AC 1,735 ms
393,844 KB
testcase_21 AC 1,725 ms
393,844 KB
testcase_22 AC 354 ms
81,516 KB
testcase_23 AC 687 ms
159,452 KB
testcase_24 AC 1,037 ms
237,556 KB
testcase_25 AC 1,383 ms
315,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

   #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)

    typedef long long ll;
    typedef unsigned long long ull;
    using P=pair<ll,ll>;
    using tp=tuple<ll,ll,ll>;
    const int INF=1001001001;
    const ll INFL=1e18;
    const int mod=1e9+7;

    void solve(){
        ll n;
        cin>>n;
        vector<ll>t(n+1);
        for(int i=1;i<=n;i++){
            t[i]=i;
        }
        ll ans=0;
        for(ll i=2;i*i<=n;i++){
            ll p=i*i;
            if(t[p]==p){
                for(ll j=p;j<=n;j+=p){
                    while(t[j]%p==0){
                        t[j]/=p;
                    }
                }
            }
        }
        for(ll a=1;a<=n;a++){
            ll x=n/t[a];
            ll cnt=sqrt(x);
            ans+=cnt;
        }
        cout<<ans<<endl;
    }

    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        solve();

        return 0;
    }
0