// Preset 생략 int n; CVector inc; CVector old; pii sol_fs() { for (int i = 1; i = 1; j--) { int jindex = j - 1; int jnum = j; if (inc[jindex] != num) continue; // num을 찾음 reverse(inc.begin() + jindex, inc.begin() + index + 1); return {jindex + 1, index + 1}; } } return {-1, -1}; } pii sol(int searchFrom) { if (searchFrom == 0) return sol_fs(); else return sol_fe(); } CVector p; void try_t1(int a,..
중첩 for문을 사용해 모든 경우의수를 전부 대입 // Preset 생략 vector ables; int n; int stx = 0, sty = 0, stz = 0, sta = 0, stb = 0, stc = 0; set used; bool included(int x) { for (int y : ables) if (x == y) return true; return false; } bool allIncluded(int x) { while (x) { if (!included(x % 10)) return false; x /= 10; } return true; } int main() { cin >> n; for (int i = 0; i > x; ables.push_ba..
이번 문제는 자르고 뒤집고 하는게 많아서 python으로 풀었다. import sys n = int(sys.stdin.readline()) password = list(map(int, sys.stdin.readline().split())) # (뒤집는 시작점, 뒤집는 끝점, 두번째 왼쪽밀기의 정도)를 저장하는 리스트 ansAbles = [] for i in range(n - 1, 0, -1): Shifted = password[i : n] + password[ : i] RevSize = 0 RevStart = -1 for j in range(n - 1): if (Shifted[j] - 1 > 0 and Shifted[j + 1] == Shifted[j] - 1) or (Shifted[j] - 1 == 0..
// 프리셋 생략 int n, ans = 0; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); cin >> n; // 변 // a,b,c // a c) ans++; } } cout
Preset이 600줄이 넘어서 따로 만들기로 했다. Preset은 #203 을 참고하자. BigInt를 어디서 가져왔다. 대회에 이런 문제가 나온다면 내 손으로 구현해야 하겠지만.. // [Preset 생략]... int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); string a, b; while (1) { cin >> a >> b; if (a == "0" || b == "0") break; BigInt ba(a), bb(b); if (ba > bb) swap(ba, bb); // ba < bb cout
610줄이 말인가.. Javascript의 Array를 Clone coding한 CVector와 https://codeforces.com/blog/entry/16380에서 가져온 BigInt가 포함되어 있다. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define interface struct #define zx3f 1061109567 #define itn int #define _DEBUG_ 0 #define dout \ if (_DEBUG_) \ cout typedef..
#include #include #include #include #include #include #include #include #include #include #include using namespace std; #define interface struct #define zx3f 1061109567 #define itn int #define _DEBUG_ 0 #define dout \ if (_DEBUG_) \ cout typedef long long ll; typedef unsigned long ull; typedef pair pii; typedef signed char i8; typedef short i16; typedef int i32; typedef long long i64; int dx[] =..
#include #include #include #include #include #include #include #include #include #include #include using namespace std; #define interface struct #define zx3f 1061109567 #define itn int #define _DEBUG_ 0 #define dout \ if (_DEBUG_) \ cout typedef long long ll; typedef unsigned long ull; typedef pair pii; typedef signed char i8; typedef short i16; typedef int i32; typedef long long i64; int dx[] =..
각을 분수로 표현해서 구한다. r = 3일때 1번째는 0/3, 2번 째는 1/3, 3번째는 2/3으로 만든다. r = 6일때 2번째는 2/6, 그러니까 1/3 인데 r = 3 일때 1/3이 존재했다는걸 알 수 있다. 이런식으로 [몇번 째 인지] - 1 / [r] 을 기약분수로 만들어 가려지는지 확인할 수 있다. 기약분수로 만들때는 gcd를 사용하자. #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define interface struct #define zx3f 1061109567 #define itn int #define..