답안 #22490

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
22490 2017-04-30T05:04:11 Z 팀명을 한번 정하면 못바꿀까?(#898, qja0950) Unifying Values (KRIII5_UV) C++14
0 / 7
6 ms 1644 KB
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <string.h>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
typedef pair<int, int> pi;

const int MOD = 1e9 + 7, MAX_N = 1e4 + 10;

int N; ll Nr[MAX_N], Sum[MAX_N];
int Cnt[MAX_N];
vector<ll> list;
int getIx(ll v) {return lower_bound(list.begin(), list.end(), v) - list.begin();}
bool welldiv(ll a, ll b) {
	if(b == 0) return a == 0;
	return abs(a) % abs(b) == 0;
}
int main() {
	scanf("%d", &N);
	for(int i=1; i<=N; i++) scanf("%lld", &Nr[i]), list.push_back(Sum[i] = Sum[i-1] + Nr[i]);
	list.push_back(0), sort(list.begin(), list.end()); list.erase(unique(list.begin(), list.end()), list.end());

	ll all = Sum[N], ans = 0;
	for(ll val : list) {
		if(welldiv(all, val) == false) continue;
		for(int i=0; i<=N; i++) Cnt[i] = 0;
		Cnt[getIx(0)] = 1;
		for(int i=1; i<=N; i++) {
			if(welldiv(Sum[i], val) == false) continue;
			ll pre = Sum[i] - val;
			Cnt[getIx(Sum[i])] += Cnt[getIx(pre)]; Cnt[getIx(Sum[i])] %= MOD;
		}
//		printf("%lld : %d\n", val, Cnt[getIx(all)]);
		ans += Cnt[getIx(all)]; ans %= MOD;
	}
	ans += (MOD - 1); ans %= MOD;
	printf("%lld\n", ans);
	return 0;
}

Compilation message

UV.cpp: In function 'int main()':
UV.cpp:28:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
                 ^
UV.cpp:29:90: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1; i<=N; i++) scanf("%lld", &Nr[i]), list.push_back(Sum[i] = Sum[i-1] + Nr[i]);
                                                                                          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1372 KB Output is correct
2 Correct 0 ms 1372 KB Output is correct
3 Incorrect 0 ms 1372 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1644 KB Output isn't correct
2 Halted 0 ms 0 KB -