結果

問題 No.1063 ルートの計算 / Sqrt Calculation
ユーザー zezerozezero
提出日時 2020-05-29 22:10:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 542 ms
コンパイル使用メモリ 70,432 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 22:47:00
合計ジャッジ時間 1,097 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:28:21: warning: 'ansa' may be used uninitialized [-Wmaybe-uninitialized]
   28 |     cout << ansa << " " << ansb << endl;
      |                     ^~~
main.cpp:17:9: note: 'ansa' was declared here
   17 |     int ansa,ansb;
      |         ^~~~
main.cpp:28:28: warning: 'ansb' may be used uninitialized [-Wmaybe-uninitialized]
   28 |     cout << ansa << " " << ansb << endl;
      |                            ^~~~
main.cpp:17:14: note: 'ansb' was declared here
   17 |     int ansa,ansb;
      |              ^~~~

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <deque>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)


int main(){
    int n;
    cin >> n;
    int now = 1;
    int a = 1,b;
    int ansa,ansb;

    while(now <= n){
        if (n%now == 0){
            ansa = a;
            ansb = n/now;
        }
        now = (a+1)*(a+1);
        a++;
    }
    
    cout << ansa << " " << ansb << endl;
   return 0;

}
0