結果

問題 No.300 平方数
ユーザー tetsuzuki1115tetsuzuki1115
提出日時 2017-09-29 08:28:40
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 810 bytes
コンパイル時間 517 ms
コンパイル使用メモリ 80,240 KB
実行使用メモリ 11,200 KB
最終ジャッジ日時 2024-04-27 16:04:07
合計ジャッジ時間 1,864 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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