結果

問題 No.300 平方数
ユーザー tetsuzuki1115tetsuzuki1115
提出日時 2017-09-29 08:42:10
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 878 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 78,668 KB
実行使用メモリ 11,148 KB
最終ジャッジ日時 2024-04-27 16:04:18
合計ジャッジ時間 4,933 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,816 KB
testcase_01 AC 3 ms
6,944 KB
testcase_02 AC 3 ms
6,944 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 3 ms
6,944 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 3 ms
6,944 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 AC 16 ms
11,148 KB
testcase_14 AC 3 ms
6,944 KB
testcase_15 AC 3 ms
6,940 KB
testcase_16 AC 4 ms
6,940 KB
testcase_17 AC 3 ms
6,944 KB
testcase_18 AC 3 ms
6,944 KB
testcase_19 AC 3 ms
6,944 KB
testcase_20 RE -
testcase_21 AC 4 ms
6,944 KB
testcase_22 AC 4 ms
6,940 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 AC 4 ms
6,940 KB
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 AC 5 ms
6,940 KB
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:44:17: warning: iteration 999998 invokes undefined behavior [-Waggressive-loop-optimizations]
   44 |         if ( A[i]%2 ) { ans *= i; }
      |              ~~~^
main.cpp:42:30: note: within this loop
   42 |     for ( long long i = 2; i <= 1000000; i++ ) {
      |                            ~~^~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;


long long A[1000000] = {0};

int main() {
    
    long long X;
    cin >> X;
    
    long long x = X;
    
    for ( long long i = 2; i*i <= x; i++ ) {
        
        int j = 0;
        while ( X%i == 0 ) {
            X /= i;
            j++;
        }
        A[i] = j;
        
        if ( X == 1 ) { break; }
    }
    if ( X != 1 ) { A[X] = 1; }
    
    long long ans = 1;
    for ( long long i = 2; i <= 1000000; i++ ) {
        // if ( A[i] ) { cout << i << " " << A[i] << endl; }
        if ( A[i]%2 ) { ans *= i; }
    } 
    cout << ans << endl;
    
    
    return 0;
}
0