반응형

인텔리제이에서 vscode의 Ctrl + D (같은 단어 선택) 기능 KeyMap에서 찾기

 

vscode를 이용할 때 같은 단어를 여러개 선택하려면 ctrl+d 키를 여러번 누르면 된다.

인텔리제이에서도 동일한 기능이 존재했다.

다만 인텔리제이 버전이나 운영체제(윈도우, 맥, 리눅스)에 따라 단축키가 다르게 설정되어 있어

이를 편하게 이용하려면 변경이 필요하다.

 

많은 블로그의 글에서 단축키를 알려주지만 해당 단축키를 KeyMap에서 찾는 기능은

잘 소개를 안해주는 것 같아서 글을 쓴다.

 

 

 


 

 

 

Add Selection for Next Occurence

인텔리제이에서 vscode ctrl+d 의 단축키 기능의 이름은

'Add Selection for Next Occurence' 이다.

해당 기능의 단축키를 변경하기 위해

 

인텔리제이 메뉴에서

File -> Settings -> KeyMap으로 이동해서

검색창에 occur을 검색해서 'Add Selection for Next Occurence' 를 찾아

우클릭하여 keyboard shortcut 을 추가해주면 단축키가 설정된다.

만약 나처럼 ctrl+d를 단축키로 이용하려면

이미 인텔리제이에서는 ctrl+d가 다른 기능으로 맵핑되어 있기 때문에

이미 맵핑되어 있는 기능을 다 제거해주어야 한다.

위와 같은 warning 문구가 나타나면 remove를 해야

 

내가 새로 설정한 키로 기능을 올바르게 이용할 수 있다.

 

 

 

 

 

 

Add Selection for Next Occurence와 유사한 단축키 설명

https://blog.jetbrains.com/idea/2014/03/intellij-idea-13-1-rc-introduces-sublime-text-style-multiple-selections/

 

IntelliJ IDEA 13.1 RC Introduces Sublime Text Style Multiple Selections | The IntelliJ IDEA Blog

We have two exciting pieces of news for you today.First of all, IntelliJ IDEA 13.1 RC is now available for download, so you can try all the new features right away. By the way, this is the last chan

blog.jetbrains.com

 

반응형
반응형

App.vue

<template>
  <div>
    <h2>hello Teleport</h2>
    <teleport to="#extra-modal" :disabled="isTeleport">
      <div class="modal">
        this is modal
        <button @click="isTeleport = !isTeleport">teleport toggle</button>
      </div>
    </teleport>
    <teleport to="#extra-modal">
      <div class="modal2">this is modal2</div>
    </teleport>
  </div>
</template>
<script>
export default {
  name: "App",
  components: {},
  data() {
    return {
      isTeleport: true,
    };
  },
};
</script>

<style scoped>
.modal {
  position: fixed;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  font-size: 36px;
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>

 

index.html

<!DOCTYPE html>
<html lang="">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
    <title><%= htmlWebpackPlugin.options.title %></title>
  </head>
  <body>
    <noscript>
      <strong
        >We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
        properly without JavaScript enabled. Please enable it to
        continue.</strong
      >
    </noscript>
    <div id="app"></div>
    <div id="extra-modal"></div>
    <!-- built files will be auto injected -->
  </body>
</html>

원래는 App.vue에 작성하는 모든 내용은

index.html의 id가 app인 div태그로 들어가게 된다.

 

하지만

텔레포트를 이용하면 App.vue에 있는 내용들을

index.html 에서 id가 app인 div태그 외부로 보낼 수 있다.

반응형

'Web > Vue' 카테고리의 다른 글

[Vue] slot  (0) 2022.06.29
[Vue] Component5 , keep-alive, dynamic component  (0) 2022.06.29
[Vue] Component4, your input is  (0) 2022.06.29
[Vue] Component 3  (0) 2022.06.29
[Vue] Component 2  (0) 2022.06.25
반응형

app.vue

<template>
  <div>
    <h2>hello slots</h2>
    <CardView
      ><template v-slot:header>
        <h3>Random Image</h3>
      </template>
      <template v-slot:default>
        <img src="https://placeimg.com/200/100/any" alt="" />
      </template>
      <template v-slot:footer>
        <small>thank you</small>
      </template>
    </CardView>
  </div>
</template>
<script>
import CardView from "./components/slot/CardView";
export default {
  name: "App",
  components: { CardView },
  data() {
    return {};
  },
};
</script>

<style></style>

 

CardView.vue

<template>
  <div class="card">
    <div class="card-header"><slot name="header"></slot></div>
    <div class="card-body"><slot></slot></div>
    <div class="card-footer"><slot name="footer"></slot></div>
  </div>
</template>

<script>
export default {};
</script>

<style scoped>
.card {
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.3);
  padding: 1rem;
  margin-bottom: 1rem;
  width: 200px;
}

.card-header {
  color: red;
}
.card-body {
  color: green;
}

.card-footer {
  color: pink;
}
</style>

 

반응형

'Web > Vue' 카테고리의 다른 글

[Vue] teleport  (0) 2022.06.29
[Vue] Component5 , keep-alive, dynamic component  (0) 2022.06.29
[Vue] Component4, your input is  (0) 2022.06.29
[Vue] Component 3  (0) 2022.06.29
[Vue] Component 2  (0) 2022.06.25
반응형

App.vue

<template>
  <div>
    <!-- <CompLevel1></CompLevel1> -->
    <h2>Hello Component</h2>
    <!-- <button @click="clickMenu(0)">Menu1</button>
    <button @click="clickMenu(1)">Menu2</button>
    <button @click="clickMenu(2)">Menu3</button>
    <Menu1 v-if="displayMenu[0]"></Menu1>
    <Menu2 v-if="displayMenu[1]"></Menu2>
    <Menu3 v-if="displayMenu[2]"></Menu3> -->

    <button @click="activeTab = 'Menu1'">Menu1</button>
    <button @click="activeTab = 'Menu2'">Menu2</button>
    <button @click="activeTab = 'Menu3'">Menu3</button>
    <!-- 
    <Menu1 v-if="activeTab === 'Menu1'"></Menu1>
    <Menu2 v-if="activeTab === 'Menu2'"></Menu2>
    <Menu3 v-if="activeTab === 'Menu3'"></Menu3> -->
    <!-- dynamic component -->
    <!-- is에 컴포넌트 명만 넘겨주면 해당 컴포넌트가 나오게 된다! -->
    <keep-alive>
      <component :is="activeTab"></component>
    </keep-alive>
  </div>
</template>
<script>
import Menu1 from "./components/tabItems/Menu1";
import Menu2 from "./components/tabItems/Menu2";
import Menu3 from "./components/tabItems/Menu3";
// import CompLevel1 from "./components/provider-inject/CompLevel1";
export default {
  name: "App",
  components: {
    // CompLevel1,
    Menu1,
    Menu2,
    Menu3,
  },
  data() {
    return {
      // displayMenu: [false, false, false],
      username: "scalper",
      activeTab: "Menu1",
    };
  },
  provide() {
    return {
      name: this.username,
    };
  },
  methods: {
    clickMenu(num) {
      this.displayMenu[num] = this.displayMenu[num] ? false : true;
    },
  },
};
</script>

<style></style>

 

 

Menu1.vue

<template>
  <h2>Menu1</h2>
</template>

<script>
export default {
  name: "MyMenu1",
};
</script>

<style></style>

 

 

Menu2.vue

<template>
  <h2>Menu2</h2>
</template>

<script>
export default {
  name: "MyMenu2",
};
</script>

<style></style>

 

 

Menu3.vue

<template>
  <h2>Menu3</h2>
  <!-- 다른 메뉴로 옮기면 input 새로 렌더링 되서 사라진다<br /> -->
  <input type="text" v-model="username" />
</template>

<script>
export default {
  name: "MyMenu3",
  data() {
    return {
      username: "",
    };
  },
};
</script>

<style></style>

 

 

 

반응형

'Web > Vue' 카테고리의 다른 글

[Vue] teleport  (0) 2022.06.29
[Vue] slot  (0) 2022.06.29
[Vue] Component4, your input is  (0) 2022.06.29
[Vue] Component 3  (0) 2022.06.29
[Vue] Component 2  (0) 2022.06.25
반응형

App.vue

 

<template>
  <div>
    <h2>Your Input is!</h2>
    <h3>{{ input }}</h3>
    <button @click="displayDetail = true">입력하기</button>
    <DetailView
      v-if="displayDetail"
      @closeDetail="close"
      @sendData="showData"
    ></DetailView>
  </div>
</template>
<script>
import DetailView from "./components/DetailView.vue";
export default {
  name: "App",
  components: {
    DetailView,
  },
  data() {
    return {
      displayDetail: false,
      input: "default",
    };
  },
  methods: {
    close() {
      this.displayDetail = false;
    },
    showData(data) {
      this.input = data;
    },
  },
};
</script>

<style></style>

 

 

Defalut.vue

<template>
  <div class="wrapper">
    <div class="container">
      <h2>Detail Page</h2>
      <button @click="closeDetail">close</button>
      <input type="text" v-model="username" />
      <button @click="sendData">send Data</button>
    </div>
  </div>
</template>

<script>
export default {
  name: "detailPage",
  data() {
    return {
      username: "",
    };
  },
  methods: {
    closeDetail() {
      this.$emit("closeDetail");
    },
    sendData() {
      this.$emit("sendData", this.username);
      this.closeDetail();
    },
  },
};
</script>

<style scoped>
.wrapper {
  background: rgba(0, 0, 0, 0.5);
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
.container {
  background: #fff;
  width: 60%;
}
</style>

 

 

자식은 부모의 데이터를 변환할 수 없다.

단 자식의 이벤트를 부모에게 넘겨주어서

부모에서 처리해줄 수 있다.

부모에게 이벤트를 전달할 땐 emit을 해주고 뒤에 파라미터를 넣어줄 수 있다.

반응형

'Web > Vue' 카테고리의 다른 글

[Vue] slot  (0) 2022.06.29
[Vue] Component5 , keep-alive, dynamic component  (0) 2022.06.29
[Vue] Component 3  (0) 2022.06.29
[Vue] Component 2  (0) 2022.06.25
[Vue] Component 1  (0) 2022.06.25
반응형

https://www.acmicpc.net/problem/16563

 

16563번: 어려운 소인수분해

첫째 줄에는 자연수의 개수 N (1 ≤ N ≤ 1,000,000)이 주어진다. 둘째 줄에는 자연수 ki (2 ≤ ki ≤ 5,000,000, 1 ≤ i ≤ N)가 N개 주어진다.

www.acmicpc.net

1.문제설명

에라토스테네스의 체를 이용하여 소인수분해를 해야하는 문제이다.

 

빠른 소인수분해를 위해 에라토스테네스의 체를 이용해서

단순히 소수를 판별하는 것을 넘어서

Prime[x] = y , x의 소인수 중 가장 작은 소수 y값을 저장하면

이를 바탕으로 소인수분해를 빠르게 할 수 있다.

 

 

예를 들어 10을 소인수 분해 할 때

Prime 배열은 다음과 같다

1 2 3 4 5 6 7 8 9 10
-1 2 3 2 5 2 7 2 3 2

int x = 10 이라고 하면

Prime[x] == 2 이므로

2를 출력하고 x = x/2를 해준다

그러면 Prime[x] =5 이므로

5를 출력하고 x = x/5

 

x==1 이므로 종료한다.

 

이런식으로 에라토스테네스체를 이용하여 빠른 소인수분해를 할 수 있다.

 

 


 

2.문제풀이코드

#include <bits/stdc++.h>
using namespace std;
#define LEN 5000001


//Fast Factorization

int Prime[LEN];

//O(nloglogn)
void erathostenes(){
    Prime[0] = Prime[1] = -1;

    for(int i=2; i<LEN; i++){
        Prime[i] = i;
    }
    int sqrtn = int(sqrt(LEN));

    for(int i=2; i<=sqrtn; i++){
        for(int j=i*i; j<LEN; j+=i){
            if(Prime[j] == j){
                Prime[j] = i;
            }
        }
    }
}

//아마도 O(n) 이하
void Factorization(int num){

    while(num > 1){
        cout << Prime[num] << ' ';
        num /= Prime[num];
    }

    cout << '\n';
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);

    int t;
    cin >> t;

    erathostenes();

    for(int T=0;T<t; T++){
        int num;
        cin >> num;
        Factorization(num);
    }


    return 0;
}

백준 16563번 어려운 소인수 분해

반응형
반응형
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
bool ch[200];
bool Prime[200];


bool isPrime(int num){
    for(int i=2; i*i <=num; i++){
        if(num%i==0) return false;
    }
    return true;
}


//소인수분해
vector<ll> factorSimple(ll n){
    vector<ll> ret;

    ll sqrtn = ll(sqrt(n));
    for(ll div = 2; div<=sqrtn; div++){
        while(n%div==0){
            n/=div;
            ret.push_back(div);
        }
    }
    if(n>1) ret.push_back(n);

    return ret;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);

    ch[0] = 1;

    for(int i=2; i<100; i++){
        cout << i << ' ';
        if(isPrime(i)) cout << "is Prime" << '\n';
        else cout << "is not Prime" << '\n';
    }

    
    
    //slow erathostenes
    for(int i=2; i<200/2 + 1; i++){
        if(ch[i]==0){
            for(int j=i+i; j<200; j+=i){
                ch[j] = 1;
            }
        }
    }

    //fast erathostenes;
    int sqrtn = int(sqrt(200));
    for(int i=2; i<=sqrtn; i++) {
        if (Prime[i])
            for (int j = i * i; j <= 200; j++) {
                Prime[i] = 1;
            }
    }
    
    
    return 0;
}

i 가 루트 n보다 큰 경우에는

이미 이전에 계산한 적이 있기 때문에 생략할 수 있고,

j가 i*i보다 작은 경우도 마찬가지로

i가 i-1이하일 때 이미 계산된 적이 있기 때문에 생략할 수 있다.

 

그래서 보다 에라스토테네스 알고리즘을 최적화 할 수 있다.

반응형
반응형

https://www.acmicpc.net/problem/2470

 

2470번: 두 용액

첫째 줄에는 전체 용액의 수 N이 입력된다. N은 2 이상 100,000 이하이다. 둘째 줄에는 용액의 특성값을 나타내는 N개의 정수가 빈칸을 사이에 두고 주어진다. 이 수들은 모두 -1,000,000,000 이상 1,000,00

www.acmicpc.net

1. 문제설명

두 용액의 합이 가장 0에 가까울 때의 두 용액의 값을 출력하는 문제이다.

 

단순하게 나올 수 있는 모든 용액의 합을 구하면 시간복잡도가 O(N^2)이 되기 때문에 틀린다.

 

우선 모든 용액의 값을 받아 정렬하고

가장 작은값과 가장 큰값을 start 지점과 end지점으로 두어서 더해본다.

 

v[start] + v[end] > 0 이라면 두 용액의 합이 0에 가까워지기 위해서

두용액의 합을 줄여야한다.

 

이 때 이미 모든 용액은 오름차순으로 정렬되어 있기 때문에 두 용액의 합을 줄이기 위해서는

end의 값을 줄여야한다

 

반대로 v[start] + v[end] < 0 일 때는 두 용액의 합이 0에 가까워지기 위해

두 용액의 합을 키워야하므로

start의 값을 키워야한다.

 

이 과정을 start < end 인 동안 반복한다.

두 용액은 다른 용액을 사용해야 하기 때문에 start==end가 되어서는 안된다.

 

이 과정을 반복하면 abs(v[start] + v[end])가 최소가 되는 지점을 찾을 수 있다.

이를 코드로 옮기면 된다.

 

 

정렬할 때 시간복잡도 O(NlogN)

start, end를 찾는 과정 O(N) 이므로

O(NlogN)으로 이 문제를 해결 할 수 있다.

 

 


2.문제풀이코드

#include <bits/stdc++.h>
using namespace std;

int n;
vector<int> v;

int main(){
    ios::sync_with_stdio(0); cin.tie(0);

    cin >> n;
    for(int i=0; i<n; i++){
        int num;
        cin >> num;
        v.push_back(num);
    }

    sort(v.begin(), v.end());


    int st = 0, en = n-1;

    int ans_val = INT_MAX;

    int ans1, ans2;
    while(st < en){
        int sum = v[st] + v[en];
        if(sum==0) {
            cout << v[st] << ' ' << v[en];
            return 0;
        }

        if(ans_val >= abs(sum)){
            ans_val = abs(sum);
            ans1 = v[st];
            ans2 = v[en];
        }

        //두합이 0보다 크다면 en의 값을 줄여야하고 0보다 작다면 st의 값을 증가시킨다.
        if(sum > 0){
            en--;
        }
        else{
            st++;
        }
    }

    cout << ans1 << ' ' << ans2;


    return 0;
}

백준 2470번

 

반응형

+ Recent posts