結果

問題 No.3236 累乗数大好きbot
ユーザー tnakao0123
提出日時 2025-08-16 12:46:27
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 325 ms / 4,000 ms
コード長 760 bytes
コンパイル時間 516 ms
コンパイル使用メモリ 66,848 KB
実行使用メモリ 46,200 KB
最終ジャッジ日時 2025-08-16 12:46:42
合計ジャッジ時間 11,394 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:39:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |   scanf("%d", &tn);
      |   ~~~~~^~~~~~~~~~~
main.cpp:43:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   43 |     scanf("%lld", &n);
      |     ~~~~~^~~~~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 3236.cc:  No.3236 邏ッ荵玲焚螟ァ螂ス縺甲ot - yukicoder
 */

#include<cstdio>
#include<unordered_map>
#include<algorithm>

using namespace std;

/* constant */

const long long MAX_N = 1000000000000LL;

/* typedef */

using ll = long long;
using umli = unordered_map<ll,int>;

/* global variables */

/* subroutines */

/* main */

int main() {
  umli aes;
  for (int x = 2; (ll)x * x <= MAX_N; x++) {
    ll xe = (ll)x * x;
    if (aes.count(xe)) continue;
    aes[xe] = 2;

    xe *= x;
    for (int e = 3; xe <= MAX_N; xe *= x, e++) aes[xe] = e;
  }
  
  int tn;
  scanf("%d", &tn);

  while (tn--) {
    ll n;
    scanf("%lld", &n);

    int e = aes.count(n) ? aes[n] : 1;
    printf("%d\n", e);
  }

  return 0;
}
0