문제링크 : https://www.acmicpc.net/problem/2885#include using namespace std;typedef long long ll;int K, num=1, min_num;int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> K; while(num =tmp) { min_num = cnt; K-=tmp; } tmp/=2; cnt++; } cout 초콜릿의 크기는 항상 2의 제곱 형태이기 때문에, 우선 입력받은 K 값보다 큰 2의 제곱 값을 구한다.이후에 해당 값을 2를 나눈 값을..
문제링크 : https://www.acmicpc.net/problem/14929#include using namespace std;typedef long long ll;int arr[100001];int sum[100001];int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; for(int i=0; i> arr[i]; if(i==0) sum[0]=arr[0]; else sum[i] = sum[i-1] + arr[i]; } ll result = 0; for(int i=0; i 주어진 공식에 따라 식을 살펴보면 다음과 같다.x1(x2+x3+x..
문제 링크 : https://www.acmicpc.net/problem/3060#include using namespace std;typedef long long ll;int T;int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> T; while(T--) { int N, num, sum = 0, cnt = 0; cin >> N; for(int i=0; i> num; sum += num; } int require = 1; while(1) { cnt++; if(N..
문제 링크 : https://www.acmicpc.net/problem/1614#include using namespace std;typedef long long ll;ll f, n;int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> f >> n; ll sum = 0; if(f==1) sum = n*8; else if(f==2) { if(n%2==0) sum = n*4+1; else sum = n*4+3; } else if(f==3) sum = n*4+2; else if(f==4) { if(n%2==0) sum = n*..