結果

問題 No.1232 2^x = x
ユーザー udonmanudonman
提出日時 2020-09-22 15:47:39
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,959 bytes
コンパイル時間 1,013 ms
コンパイル使用メモリ 116,096 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 11:49:20
合計ジャッジ時間 1,772 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(15) << << endl;
#include <cassert>
//#include "atcoder/all"

using namespace std;
//using namespace atcoder;

typedef long long ll;

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define P pair<int,int>

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
ll mod = 1000000007;

template <typename T>
class SegTree{
public:
    vector<T> dat;
    int N = 1;
    ll INF = (1ll<<31);

public:
    SegTree(vector<T> v)
    {
        int sz = v.size();
        while(N < sz) N *= 2;
        dat.resize(2*N-1);
        for(int i = 0; i < sz; ++i) dat[N-1+i] = v[i];
        for(int i = N-2; i >= 0; --i) dat[i] = min(dat[i*2+1], dat[i*2+2]);
    }
    void update(int i, T x)
    {
        i += N - 1;
        dat[i] = x;
        while(i > 0)
        {
            i = (i - 1) / 2;
            dat[i] = min(dat[2*i+1], dat[2*i+2]);
        }
    }

    //最初はquery(a,b,0,0,N)を呼び出す
    T query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return INF;
        else if(a <= l && r <= b) return dat[k];
        else
        {
            T c1 = query(a, b, 2*k+1, l, (r+l)/2);
            T c2 = query(a, b, 2*k+2, (r+l)/2, r);
            return min(c1, c2);
        }
    }
};

int main(){
    ios::sync_with_stdio(false);

    int n; cin >> n;

    while(n--){
        ll p; cin >> p;
        if(p!=2){
            cout << (p-1)*(p-1) << endl;
        }else{
            cout << 2 << endl;
        }
    }
}
0