Problem URL : 숫자의 표현
int solution(int n) {
int answer = 0;
int a,b;
a=b=1;
int v=1;
while (a <= n) {
if(v == n){
answer ++;
v += ++b;
}else if( v < n){
v += ++b;
}else{
v -= a++;
}
}
return answer;
}
Query : Table에 PK값이 있으면 Update 없으면 Insert
INSERT INTO table_name (a, b) VALUES (?, ?) ON DUPLICATE KEY UPDATE a = ? , b = ?