Submission #19838

# Submission time Handle Problem Language Result Execution time Memory
19838 2016-02-25T06:09:48 Z inspire12 괄호 (kriii4_R) C++
0 / 100
0 ms 1576 KB
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
vector<pair<long long, long long> > x;
unsigned long long res = 1;
priority_queue<long long > q;
vector<vector<long long> > v;
vector<long long> t;
int main() {
	int n, s; long long res = 0;
	long long m;
	long long i;
	unsigned long long temp;
	pair<long long, long long> p;
	
	scanf("%d %d", &s, &n);
	t.push_back(1);
	v.push_back(t);
	t.pop_back();
	
	p.first = s;
	p.second = 1;
	x.push_back(p);

	for (int i = 2; i <= n; i++) {
		t = v.back(); v.pop_back();
		for (int j = 1; j < i; j++) {
			q.push(t[j - 1]);
			if (j == 1 && i % 2 == 0)
				continue;
			t[j - 1]++;
		}
		if (i == 2) t.push_back(i);
		else t.push_back(i - 1);
		v.push_back(t);
	}
	
	long long re = q.top(); int  y = 2;
	while(re--) {
		p.first *= ((s % 1000000007)) % 1000000007;
		p.second = y++;
		x.push_back(p);
	} long long a = 0; t = v[0]; int d = 0;
	while (d < v[0].size()) {
		a += x[t[d]-1].first;
		d++;
	}printf("%lld", a);
}
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 1576 KB SIGSEGV Segmentation fault
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -