結果

問題 No.634 硬貨の枚数1
ユーザー xxxasdfghjkxxxasdfghjk
提出日時 2018-08-13 20:41:58
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,386 bytes
コンパイル時間 1,339 ms
コンパイル使用メモリ 72,856 KB
実行使用メモリ 4,368 KB
最終ジャッジ日時 2023-10-24 16:48:41
合計ジャッジ時間 3,671 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 2 ms
4,368 KB
testcase_04 AC 2 ms
4,368 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 2 ms
4,368 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 2 ms
4,368 KB
testcase_09 AC 1 ms
4,368 KB
testcase_10 AC 2 ms
4,368 KB
testcase_11 AC 2 ms
4,368 KB
testcase_12 AC 2 ms
4,368 KB
testcase_13 AC 2 ms
4,368 KB
testcase_14 AC 2 ms
4,368 KB
testcase_15 AC 2 ms
4,368 KB
testcase_16 AC 2 ms
4,368 KB
testcase_17 AC 1 ms
4,368 KB
testcase_18 AC 2 ms
4,368 KB
testcase_19 AC 2 ms
4,368 KB
testcase_20 AC 2 ms
4,368 KB
testcase_21 AC 2 ms
4,368 KB
testcase_22 AC 2 ms
4,368 KB
testcase_23 AC 2 ms
4,368 KB
testcase_24 AC 2 ms
4,368 KB
testcase_25 AC 2 ms
4,368 KB
testcase_26 AC 2 ms
4,368 KB
testcase_27 AC 2 ms
4,368 KB
testcase_28 AC 2 ms
4,368 KB
testcase_29 AC 2 ms
4,368 KB
testcase_30 AC 2 ms
4,368 KB
testcase_31 AC 2 ms
4,368 KB
testcase_32 AC 2 ms
4,368 KB
testcase_33 AC 1 ms
4,368 KB
testcase_34 AC 2 ms
4,368 KB
testcase_35 AC 2 ms
4,368 KB
testcase_36 AC 2 ms
4,368 KB
testcase_37 AC 2 ms
4,368 KB
testcase_38 AC 2 ms
4,368 KB
testcase_39 AC 2 ms
4,368 KB
testcase_40 AC 2 ms
4,368 KB
testcase_41 AC 2 ms
4,368 KB
testcase_42 AC 2 ms
4,368 KB
testcase_43 AC 2 ms
4,368 KB
testcase_44 AC 1 ms
4,368 KB
testcase_45 AC 2 ms
4,368 KB
testcase_46 AC 2 ms
4,368 KB
testcase_47 AC 1 ms
4,368 KB
testcase_48 AC 1 ms
4,368 KB
testcase_49 AC 2 ms
4,368 KB
testcase_50 AC 2 ms
4,368 KB
testcase_51 AC 1 ms
4,368 KB
testcase_52 AC 2 ms
4,368 KB
testcase_53 AC 2 ms
4,368 KB
testcase_54 AC 2 ms
4,368 KB
testcase_55 AC 2 ms
4,368 KB
testcase_56 AC 1 ms
4,368 KB
testcase_57 AC 2 ms
4,368 KB
testcase_58 AC 2 ms
4,368 KB
testcase_59 AC 2 ms
4,368 KB
testcase_60 AC 2 ms
4,368 KB
testcase_61 AC 2 ms
4,368 KB
testcase_62 AC 2 ms
4,368 KB
testcase_63 AC 2 ms
4,368 KB
testcase_64 AC 2 ms
4,368 KB
testcase_65 AC 2 ms
4,368 KB
testcase_66 AC 2 ms
4,368 KB
testcase_67 AC 2 ms
4,368 KB
testcase_68 AC 2 ms
4,368 KB
testcase_69 AC 2 ms
4,368 KB
testcase_70 AC 2 ms
4,368 KB
testcase_71 AC 2 ms
4,368 KB
testcase_72 AC 2 ms
4,368 KB
testcase_73 AC 2 ms
4,368 KB
testcase_74 AC 2 ms
4,368 KB
testcase_75 AC 2 ms
4,368 KB
testcase_76 AC 2 ms
4,368 KB
testcase_77 AC 1 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
int delta[10010];
int dp[100001];
int main()
{
  int N;
  cin >> N;
  delta[0] = 0;
  REP(i,5000)
    delta[i+1] = delta[i] + i+1;
  if(N == *lower_bound(delta,delta+5000,N)){
    cout << 1 << endl;
    return 0;
  }else{
    REP(i,5000)
      if(N-delta[i] == *lower_bound(delta,delta+5000,N-delta[i])){
        cout << 2 << endl;
        return 0;
      }
  }
  cout << 3 << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

0