結果

問題 No.1514 Squared Matching
ユーザー auauaauaua
提出日時 2021-05-22 00:13:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,047 bytes
コンパイル時間 1,777 ms
コンパイル使用メモリ 165,124 KB
実行使用メモリ 784,704 KB
最終ジャッジ日時 2024-04-18 17:07:22
合計ジャッジ時間 32,572 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 MLE -
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 3 ms
6,944 KB
testcase_06 AC 26 ms
15,164 KB
testcase_07 AC 293 ms
152,372 KB
testcase_08 MLE -
testcase_09 MLE -
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
testcase_21 MLE -
testcase_22 AC 306 ms
159,504 KB
testcase_23 AC 616 ms
315,804 KB
testcase_24 AC 1,017 ms
472,036 KB
testcase_25 MLE -
権限があれば一括ダウンロードができます

ソースコード

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 long long 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