結果

問題 No.3692 Calculate Mu
コンテスト
ユーザー Rumain831
提出日時 2026-09-06 18:07:50
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 4 ms / 2,000 ms
+ 249µs
コード長 414 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,024 ms
コンパイル使用メモリ 172,756 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-09-06 18:08:08
合計ジャッジ時間 2,040 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

int mu_naive(ll n){
  if(n==1) return 1;
  int ans=1;
  for(ll i=2; i*i<=n; i++){
    if(n%i) continue;
    int c=0;
    while(n%i==0){
      c++, n/=i;
    }
    if(c>=2) return 0;
    ans*=-1;
  }
  if(n>1) ans*=-1;
  return ans;
}

int main(void){
  ll n; cin >> n;
  cout << mu_naive(n) << endl;
  return 0; 
}
0