- Kickstart 2016 Round B κΈ°μΆλ¬Έμ νκΈ°
- Sherlock and Parentheses
- Sherlock and Watson Gym Secrets
- Watson and Intervals
40λΆ (Start_16:46 ~ End_17:26)
3λ¬Έμ μ½κ³ λ°λ‘ νκΈ° (λ§μ§λ§ λ¬Έμ λ μ½μ§λ λͺ»ν¨)
λμ리 νλ‘μ νΈλ‘ μΈν΄ 볡μ΅κΉμ§ λͺ»νλ€.
μμ§ λͺ¨λ₯΄λ λ¨μ΄κ° λ§μμ λ¬Έμ μ΄ν΄κ° μ½μ§ μμλ€. κ±°μ μνμΌμ΄μ€λ³΄κ³ μ μΆνλ κ² κ°λ€.
μμ μκ°
- 1μ°¨ : 22 mins
-
λ¬Έμ λ₯Ό μ΄ν΄νμλ
-
νμ΄ λ°©λ²μ΄ 빨리 μκ°λ¬λ
-
Small datasetμ ν΅κ³Όνμλ
-
Large datasetμ ν΅κ³Όνμλ
cf. λ¬Έμ λ νμλλ° μ€νμ λͺ»ν΄λ΄
-
**μν μ **
- 빨리 νμλ€.
-
**μμ¬μ λ μ **
- μκ°λ³΅μ‘λ μκ°μκ³ νμλ€.
- parenthesesκ° λμ§ λͺ°λλ€.
- λ¬Έμ κ° μλλΌ μν μ μΆλ ₯ λ°μ΄ν°λ₯Ό λ³΄κ³ λ¬Έμ λ₯Ό μ΄ν΄νλ€.
#include <iostream>
#include <algorithm>
using namespace std;
int isBalanced(int left, int right) {
if(left==0 && right==0) return 1;
if(left==0 || right==0) return 0;
if(left == right) return left;
int smaller = min(left, right);
return smaller*(smaller-1)/2;
}
int main() {
int T=0, L=0, R=0;
cin >> T;
for(auto t:T) {
cin>>L>>R;
cout<<"Case #"<<t+1<<":"<<isBalanced(L,R)<<endl;
}
return 0;
}
μμ μκ°
- 1μ°¨ : 16 mins
- λ¬Έμ λ₯Ό μ΄ν΄νμλ
- νμ΄ λ°©λ²μ΄ 빨리 μκ°λ¬λ
- Small datasetμ ν΅κ³Όνμλ
- Large datasetμ ν΅κ³Όνμλ
-
**μν μ **
- λ¬Έμ μ΄ν΄κ° λΉ¨λκ³ , νμ΄ λ°©λ²μ΄ λλ¦ λΉ¨λ¦¬ μκ°λ¬λ€.
-
**μμ¬μ λ μ **
- μκ°λ³΅μ‘λ μκ°μκ³ νμλ€. 3μ€ forλ¬Έμ΄ μ¬ λ§,,,
- is divisible by μ λ»μ λͺ°λλ€. λλμ΄μ§λλ λ».(= λλ¨Έμ§κ° 0μ΄λ)
- large dataset, small dataset λͺ¨λ ν μ€νΈ λͺ»ν΄λ΄€λ€.
#include <iostream>
#include <cmath>
using namespace std;
int a=0, b=0, n=0, k=0;
bool isValid(int i, int j) {
if(i>n || j>n) return false;
int x = pow(i,a);
int y = pow(j,b);
if((x+y)%k == 0) return true;
return false;
}
int main() {
int T=0;
for(auto t : T) {
cin>>a>>b>>n>>k;
int result=0;
for(int i=0; i<n; i++) {
for(int j=0; j<n; j++) {
if(isValid(i,j)) ++result;
}
}
cout<<"Case #"<<t+1<<":"<<result<<endl;
}
return 0;
}
μμ μκ°
- 1μ°¨ : 17 mins
- λ¬Έμ λ₯Ό μ΄ν΄νμλ
- νμ΄ λ°©λ²μ΄ 빨리 μκ°λ¬λ
- Small datasetμ ν΅κ³Όνμλ
- Large datasetμ ν΅κ³Όνμλ
-
**μμ¬μ λ μ **
- λ¬Έμ μ΄ν΄κ° μμ μλλ€.
- λͺ¨λ₯΄λ λ¨μ΄κ° λ§μλ€. (intricacies, recurrences, intervalm inclusive, modulo ...)
- λ¨μ΄λ₯Ό λͺ°λΌλ λ¬Έλ§₯μ μ μΆνλ μ°μ΅μ΄ νμν κ² κ°λ€.