본문 바로가기

전체 글

(848)
[백준 2331번] 반복수열 (C++) 문제링크 : https://www.acmicpc.net/problem/2331 2331번: 반복수열 첫째 줄에 반복되는 부분을 제외했을 때, 수열에 남게 되는 수들의 개수를 출력한다. www.acmicpc.net #include using namespace std; typedef long long ll; typedef pair pii; const int MAX = 987654321; int A, P, cnt; int check[300000]; //최대값 계산 (9^5*5) void func(int n) { check[n]++; if(check[n]>=3) return; //반복되는 구간시 탈출 int tmp = 0; while(n) { tmp += pow(n%10, P); //D[n] 구하기 n/=10;..
[백준 25421번] 조건에 맞는 정수의 개수 (C++) 문제링크 : https://www.acmicpc.net/problem/25421 25421번: 조건에 맞는 정수의 개수 2개의 자릿수를 갖고 첫 번째 자리의 숫자와 두 번째 자리의 숫자의 차이가 2보다 작거나 같은 양의 정수 11, 12, 13, 21, 22, 23, 24, 31, 32, ... , 97, 98, 99가 A에 해당된다. 따라서 정답은 39이다. www.acmicpc.net #include using namespace std; typedef long long ll; typedef pair pii; const int MAX = 987654321; int N; ll dp[10][100001], result; //정수, 자릿수 int main() { ios_base::sync_with_stdio..
[백준 17427번] 약수의 합 2 (C++) 문제링크 : https://www.acmicpc.net/problem/17427 17427번: 약수의 합 2 두 자연수 A와 B가 있을 때, A = BC를 만족하는 자연수 C를 A의 약수라고 한다. 예를 들어, 2의 약수는 1, 2가 있고, 24의 약수는 1, 2, 3, 4, 6, 8, 12, 24가 있다. 자연수 A의 약수의 합은 A의 모든 약수를 더 www.acmicpc.net #include using namespace std; typedef long long ll; typedef pair pii; const int MAX = 987654321; int N; ll result; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> N; for..
[백준 2688번] 줄어들지 않아 (C++) 문제링크 : https://www.acmicpc.net/problem/2688 2688번: 줄어들지 않아 첫째 줄에 테스트 케이스의 개수 T(1
[백준 1312번] 소수 (C++) 문제링크 : https://www.acmicpc.net/problem/1312 1312번: 소수 피제수(분자) A와 제수(분모) B가 있다. 두 수를 나누었을 때, 소숫점 아래 N번째 자리수를 구하려고 한다. 예를 들어, A=3, B=4, N=1이라면, A÷B=0.75 이므로 출력 값은 7이 된다. www.acmicpc.net #include using namespace std; typedef long long ll; typedef pair pii; const int MAX = 987654321; int A, B, N, result; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> A >> B >> N; while(N--) //N번만큼 반복 ..
[백준 1769번] 3의 배수 (C++) 문제링크 : https://www.acmicpc.net/problem/1769 1769번: 3의 배수 문제가 잘 풀리지 않을 때, 문제를 바라보는 시각을 조금만 다르게 가지면 문제가 쉽게 풀리는 경험을 종종 해 보았을 것이다. 여러 가지 방법이 있지만 그 중 하나로 우리가 풀고 싶은 문제를 www.acmicpc.net #include using namespace std; typedef long long ll; typedef pair pii; const int MAX = 987654321; int X, cnt; string s; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> s; while(s.size()!=1) //한 자릿수가 될 때까지 {..
[백준 1041번] 주사위 (C++) 문제링크 : https://www.acmicpc.net/problem/1041 1041번: 주사위 첫째 줄에 N이 주어진다. 둘째 줄에 주사위에 쓰여 있는 수가 주어진다. 위의 그림에서 A, B, C, D, E, F에 쓰여 있는 수가 차례대로 주어진다. N은 1,000,000보다 작거나 같은 자연수이고, 쓰여 있는 수 www.acmicpc.net #include using namespace std; typedef long long ll; typedef pair pii; const int MAX = 987654321; int max_n; ll sum, N; int arr[6]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> N; for(int..
[백준 1747번] 소수&팰린드롬 (C++) 문제링크 : https://www.acmicpc.net/problem/1747 1747번: 소수&팰린드롬 어떤 수와 그 수의 숫자 순서를 뒤집은 수가 일치하는 수를 팰린드롬이라 부른다. 예를 들어 79,197과 324,423 등이 팰린드롬 수이다. 어떤 수 N (1 ≤ N ≤ 1,000,000)이 주어졌을 때, N보다 크거나 같고, www.acmicpc.net #include using namespace std; typedef long long ll; typedef pair pii; const int MAX = 987654321; int N; int arr[1003001]; void check() //소수체크 { memset(arr, 1, sizeof(arr)); arr[1]=0; //1은 소수 for(..