結果

問題 No.1514 Squared Matching
ユーザー gucci0512gucci0512
提出日時 2022-06-05 02:58:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,742 bytes
コンパイル時間 3,999 ms
コンパイル使用メモリ 236,568 KB
実行使用メモリ 4,432 KB
最終ジャッジ日時 2023-10-21 02:57:03
合計ジャッジ時間 11,707 ms
ジャッジサーバーID
(参考情報)
judge9 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,432 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=b-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x);
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
typedef long long ll;
typedef long double lld;
using namespace std;
using namespace atcoder;
using mint=static_modint<1000000007>;
const ll mod=998244353;
//const ll mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const string zton="0123456789";
const string atoz="abcdefghijklmnopqrstuvwxyz";
const ll inf=(1ll<<60);
ll gcd(ll a,ll b){
    ll r;
    r=a%b;
    if(r==0){
        return b;
    }
    else{
        return gcd(b,r);
    }
}
typedef pair<ll,int> P;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int eratos[201010];
    rep(i,0,201010)eratos[i]=-1;
    eratos[0]=1;
    eratos[1]=1;
    rep(i,2,201010){
        if(eratos[i]!=-1)continue;
        eratos[i]=i;
        int x=i*2;
        while(x<=201010){
            if(eratos[x]==-1){
                eratos[x]=i;
            }
            x+=i;
        }
    }
    int N;cin >> N;
    ll N2[N+1];rep(i,0,N+1)N2[i]=(i*1ll*i);
    ll ans=0;
    rep(i,1,N+1){
        map<int,int> cnt;
        int n_=i;
        while(n_!=1){
            cnt[eratos[n_]]++;
            n_/=eratos[n_];
        }
        ll m=1;
        for(P p:cnt){
            if(p.second%2==1){
                m*=p.first;
            }
        }
        ll n=N/m;
        auto iter=upper_bound(N2,N2+N+1,n);
        int id=iter-N2;
        ans+=id;
        ans--;
    }
    cout << ans << endl;
}
0