結果

問題 No.1514 Squared Matching
ユーザー auauaauaua
提出日時 2021-05-22 00:15:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 654 ms / 4,000 ms
コード長 1,043 bytes
コンパイル時間 1,579 ms
コンパイル使用メモリ 166,036 KB
実行使用メモリ 393,928 KB
最終ジャッジ日時 2024-04-18 17:07:51
合計ジャッジ時間 13,090 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 654 ms
393,820 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 10 ms
9,252 KB
testcase_07 AC 110 ms
77,768 KB
testcase_08 AC 613 ms
379,700 KB
testcase_09 AC 528 ms
332,500 KB
testcase_10 AC 570 ms
359,708 KB
testcase_11 AC 590 ms
374,736 KB
testcase_12 AC 630 ms
384,936 KB
testcase_13 AC 631 ms
390,176 KB
testcase_14 AC 632 ms
392,132 KB
testcase_15 AC 628 ms
393,208 KB
testcase_16 AC 651 ms
393,664 KB
testcase_17 AC 621 ms
393,784 KB
testcase_18 AC 631 ms
393,784 KB
testcase_19 AC 640 ms
393,928 KB
testcase_20 AC 633 ms
393,788 KB
testcase_21 AC 626 ms
393,852 KB
testcase_22 AC 102 ms
81,492 KB
testcase_23 AC 216 ms
159,412 KB
testcase_24 AC 349 ms
237,612 KB
testcase_25 AC 503 ms
315,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
//#define vec vector<ll>
//#define mat vector<vector<ll> >
#define fi first
#define se second
#define double long double
typedef int ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
//typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll MOD=998244353;
//const ll inf=INF*INF;
const ll mod=MOD;
const ll MAX=100010;




signed main(){
    ll n;cin>>n;
    ll ans=0;
    vector<ll>d(n+1,1);
    for(int i=sqrt(n)+1;i>=2;i--){
        ll k=i*i;
        ll z=i*i;
        while(k<=n){
            if(d[k]==1)d[k]=i;
            k+=z;
        }
    }
    vector<ll>cnt(n+1);
    REP(i,1,n+1){
        ll di=d[i];
        ll x=i/di/di;
        ans=ans+cnt[x];
        cnt[x]++;
    }
    ans*=2;
    ans+=n;
    cout<<ans<<endl;
}
0