답안 #140133

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
140133 2019-08-02T07:34:53 Z rdd6584 Unifying Values (KRIII5_UV) C++14
0 / 7
12 ms 504 KB
#include <cstdio>
#include <algorithm>
#include <memory.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

ll vec[10000];
int dp[10001];

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

	for (int i = 0; i < n; i++) {
		scanf("%lld", &vec[i]);
		if (i) vec[i] += vec[i - 1];
	}

	// i를 시작점으로 하는 배열 체크.
	ll ans = 0;
	for (int i = 0; i < n - 1; i++) {
		if (!vec[i] || vec[n - 1] % vec[i]) continue;
		if (vec[i] > 0 && vec[n - 1] < 0 || vec[i] < 0 && vec[n - 1] > 0) continue;
		memset(dp, 0, sizeof(dp));
		dp[1] = 1;

		printf("%lld //\n", vec[i]);

		for (int j = i + 1; j < n - 1; j++) {
			if (!vec[j] || vec[j] % vec[i]) continue;
			if (vec[i] > 0 && vec[j] < 0 || vec[i] < 0 && vec[j] > 0) continue;

			ll t = vec[j] / vec[i];
			if (t <= 10000) dp[t] = (dp[t] + dp[t - 1]) % MOD;
		}

		ll t = vec[n - 1] / vec[i];
		ans = (ans + dp[t - 1]) % MOD;

		printf("%d : %lld\n", i, ans);
	}


	if (vec[n - 1] == 0) {
		ll sum = 1;
		for (int i = 0; i < n - 1; i++)
			if (vec[i] == 0) sum = sum * 2 % MOD;

		sum += MOD - 1;
		ans += sum;
		ans %= MOD;
	}

	printf("%lld", ans % MOD);
}

Compilation message

UV.cpp: In function 'int main()':
UV.cpp:24:18: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   if (vec[i] > 0 && vec[n - 1] < 0 || vec[i] < 0 && vec[n - 1] > 0) continue;
       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~
UV.cpp:32:19: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
    if (vec[i] > 0 && vec[j] < 0 || vec[i] < 0 && vec[j] > 0) continue;
        ~~~~~~~~~~~^~~~~~~~~~~~~
UV.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
UV.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &vec[i]);
   ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 6 ms 504 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -