답안 #22727

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
22727 2017-04-30T06:59:40 Z AJAE(#998, nona1314, adman, wowoto9772) Unifying Values (KRIII5_UV) C++14
0 / 7
66 ms 2408 KB
#include <iostream>
#include <algorithm>
#include <vector>

#define MOD 1000000007
#define ll long long

using namespace std;

ll d[10005];
ll nu[10005];
ll fact[10005] = { 1,1 };

int main() {
	for (int i = 2; i <= 10000; i++)
		fact[i] = (fact[i - 1] * i) % MOD;

	int n; 
	scanf("%d", &n);

	for (int i = 1; i <= n; i++) {
		scanf("%lld", &d[i]);
		nu[i] = nu[i - 1] + d[i];
	}
	ll ans = 0;
	int zerochk = 0;

	for (int i = 1; i < n; i++) {
		ll s = nu[i]; // ���͹�
		vector <ll> dp(n+1);
		dp[0] = 0, dp[1] = 1;
		int mx = 1;

		if (s == 0) {
			if (nu[n] != 0) continue;
		}
		if (s != 0) {
			if (nu[n] % s != 0) continue;
		}

		if (s == 0) {
			if (zerochk == 1) continue;
			zerochk = 1;
			int cnt = 0;
			ll nu = 0;
			for (int j = i + 1; j <= n; j++) {
				nu += d[j];
				if (nu == 0) cnt++;
			}
			ans = (ans +  fact[cnt]) % 1000000007;
		}
		else {
			for (int j = i + 1; j <= n; j++) {
				if (nu[j] % s == 0) {
					int x = nu[j] / s;
					if (x < 1) continue;
					if (mx >= x - 1) {
						dp[x] = (dp[x] + dp[x - 1]) % 1000000007;
						mx = max(x, mx);
					}
				}
			}
			if (mx >= nu[n] / s) {
				if (nu[n] == s) continue;
				ans = (ans + dp[nu[n] / s - 1]) % 1000000007;
			}
		}
	}
	printf("%lld", ans);
}

Compilation message

UV.cpp: In function 'int main()':
UV.cpp:19:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
UV.cpp:22:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &d[i]);
                       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2252 KB Output is correct
2 Correct 0 ms 2252 KB Output is correct
3 Correct 0 ms 2252 KB Output is correct
4 Correct 59 ms 2408 KB Output is correct
5 Correct 66 ms 2408 KB Output is correct
6 Incorrect 53 ms 2408 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 59 ms 2408 KB Output isn't correct
2 Halted 0 ms 0 KB -