結果

問題 No.1514 Squared Matching
ユーザー umezoumezo
提出日時 2021-05-22 00:54:03
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,631 ms / 4,000 ms
コード長 725 bytes
コンパイル時間 2,082 ms
コンパイル使用メモリ 198,400 KB
実行使用メモリ 393,976 KB
最終ジャッジ日時 2024-04-18 17:17:15
合計ジャッジ時間 39,822 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 985 ms
198,600 KB
testcase_01 AC 1,611 ms
393,848 KB
testcase_02 AC 995 ms
198,512 KB
testcase_03 AC 980 ms
198,508 KB
testcase_04 AC 996 ms
198,496 KB
testcase_05 AC 980 ms
198,580 KB
testcase_06 AC 988 ms
201,592 KB
testcase_07 AC 1,079 ms
235,804 KB
testcase_08 AC 1,585 ms
386,772 KB
testcase_09 AC 1,502 ms
363,116 KB
testcase_10 AC 1,598 ms
376,748 KB
testcase_11 AC 1,549 ms
384,284 KB
testcase_12 AC 1,573 ms
389,444 KB
testcase_13 AC 1,588 ms
392,004 KB
testcase_14 AC 1,574 ms
392,948 KB
testcase_15 AC 1,606 ms
393,436 KB
testcase_16 AC 1,631 ms
393,752 KB
testcase_17 AC 1,582 ms
393,976 KB
testcase_18 AC 1,583 ms
393,828 KB
testcase_19 AC 1,622 ms
393,808 KB
testcase_20 AC 1,570 ms
393,824 KB
testcase_21 AC 1,600 ms
393,828 KB
testcase_22 AC 1,073 ms
237,672 KB
testcase_23 AC 1,214 ms
276,600 KB
testcase_24 AC 1,388 ms
315,712 KB
testcase_25 AC 1,513 ms
354,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int B[50000010];

int main(){
  int n;
  cin>>n;
  
  int MAX=50000010;
  vector<int> prime(MAX,1);
  prime[0]=0,prime[1]=0;
  for(int i=2;i*i<=MAX;i++){
    if(!prime[i]) continue;
    for(int j=2*i;j<=MAX;j+=i) prime[j]=0;
  }
  vector<int> A;
  for(int i=1;i*i<=n;i++){
    if(prime[i]) A.push_back(i);
  }
  
  rep(i,n+1) B[i]=i;
  for(auto p:A){
    int q=p*p;
    int r=q;
    while(1){
      for(int i=q;i<=n;i+=q) B[i]/=r;
      if(q>n/r) break;
      q*=r;
    }
  }

  int ans=0;
  for(int i=1;i<=n;i++) ans+=sqrt(n/B[i]);
  cout<<ans<<endl;
  
  return 0;
}
0