結果

問題 No.1022 Power Equation
ユーザー SSRSSSRS
提出日時 2020-04-10 22:08:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 667 bytes
コンパイル時間 1,496 ms
コンパイル使用メモリ 163,868 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-14 00:44:09
合計ジャッジ時間 2,386 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int logfloor(int a, long long b){
  //floor(log_a(b))
  if (a > b){
    return 0;
  } else {
    int res = 1;
    long long A = a;
    while (A * a <= b){
      A *= a;
      res++;
    }
    return res;
  }
}
int main(){
  int T;
  cin >> T;
  for (int i = 0; i < T; i++){
    long long N;
    cin >> N;
    long long ans = N * N * 2 - N;
    for (int j = 2; j * j <= N; j++){
      //j: base
      int X = logfloor(j, N);
      for (int k = 1; k <= X; k++){
        for (int l = 1; l <= X; l++){
          if (k != l){
            ans += N / max(k, l);
          }
        }
      }
    }
    cout << ans << endl;
  }
}
0