회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
2
채점 현황
랭킹
게시판
그룹
더 보기
재채점 기록
블로그
강의
실험실
도움말
BOJ Stack
BOJ Book
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
반례를 알고 싶습니다..
2407번 - 조합
sunio00000
5년 전
0
빅인티져 자료형 만들어서 계산했는데 틀린 부분을 쉽게 찾을 수가 없어서 질문드립니다.
#include <iostream> #include <string> using namespace std; typedef long long ll; int n, m; ll Limit = 100000000000000; // 10^15 class Bi { private: ll num[30]; int pos; public: Bi() { for (int i = 0; i < 30; ++i) { this->num[i] = 0; } this->pos = 0; } Bi operator+(const Bi n) { Bi ret; if (this->pos >= n.pos) { ret.pos = this->pos; for (int j = 0; j <= this->pos; ++j) { if (j > n.pos) { ret.num[j] += this->num[j]; continue; } ll tmp = this->num[j] + n.num[j]; // < long long value if (tmp > Limit) { ret.num[j] += tmp % (ll)Limit; ret.num[j + 1]++; if (this->pos < j + 1) ret.pos = j + 1; } else { ret.num[j] += tmp; } } } else { ret.pos = n.pos; for (int j = 0; j <= n.pos; ++j) { if (j > this->pos) { ret.num[j] += n.num[j]; continue; } ll tmp = this->num[j] + n.num[j]; if (tmp > Limit) { ret.num[j] += tmp % (ll)Limit; ret.num[j + 1]++; if (n.pos < j + 1) ret.pos = j + 1; } else { ret.num[j] += tmp; } } } return ret; } int hasValue() { return this->num[0]; } void setValue(ll i) { this->num[0] = i; } int getPos() { if (this->pos>=0) return this->pos; else return -1; } ll getValue(int pos) { return this->num[pos]; } }; Bi cache[101][101]; // nCm = n! / (m! * (n-m)!) // nCm = n-1Cm + n-1Cm-1 // n&m + n|m = n+m // nC0 = 0C0 = 1 int main() { cin >> n >> m; for (ll i = 0; i <= n; ++i) { for (ll j = 0; j <= m && j <= i; ++j) { if (cache[i][j].hasValue()) continue; else if (i == 0 && j == 0) { cache[i][j].setValue(1LL); continue; } else if (i == 1 || j == 0) { cache[i][j].setValue(1LL); continue; } else if (j == 1) { cache[i][j].setValue(i); continue; } cache[i][j] = cache[i - 1][j] + cache[i - 1][j - 1]; // cout << "cache[" << i << "][" << j << "] =" << cache[i][j].getValue(0)<< "\n"; } } for (int i = cache[n][m].getPos(); i >= 0; --i) { cout << cache[n][m].getValue(i); } cout << '\n'; // cout << cache[n][m] << endl; system("pause"); return 0; }
sunio00000
5년 전
1
65 50 반례 하나 찾았습니다.
댓글을 작성하려면
로그인
해야 합니다.
sunio00000 5년 전
빅인티져 자료형 만들어서 계산했는데 틀린 부분을 쉽게 찾을 수가 없어서 질문드립니다.