답안 #22624

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
22624 2017-04-30T05:59:36 Z 크리님 제가 귀여우면 됬지 뭘 더 원하세요 진짜(#952, sys7961, hyorothy, skdudn321) Unifying Values (KRIII5_UV) C++14
0 / 7
36 ms 1780 KB
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<list>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<functional>
#include<cmath>
#include<string>

#define sd(a) scanf("%d", &a);
#define sld(a) scanf("%lld", &a);
#define MOD 1000000007

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;

lli N;
vector<lli> ve;
set<lli> se;

lli cal(lli A, lli B) {
	lli ret = 1;
	while (B != 0) {
		if (B % 2 == 0) {
			A *= A;
			A %= MOD;
			B /= 2;
		}
		else {
			ret *= A;
			ret %= MOD;
			B--;
		}
	}

	return ret;
}

int main(void) {
	sld(N);
	for (int i = 1; i <= N; i++) {
		lli temp;
		sld(temp);
		ve.push_back(temp);
	}

	lli ans = 0;
	lli start_value = 0;
	for (int i = 0; i < N; i++) {
		start_value += ve[i];
		if (se.count(start_value) == 1) {
			continue;
		}
		se.insert(start_value);

		bool check = false;
		
		lli count = 1;
		lli cur = 0;
		lli temp_count = 1;
		lli aa = 0;
		for (int j = i + 1; j < N; j++) {
			cur += ve[j];
			if (cur == 0) {
				temp_count++;
				if (j == N - 1 && aa > 0) {
					check = true;
				}
			}
			else if (cur == start_value) {
				count *= temp_count;
				count %= MOD;
				temp_count = 1;
				cur = 0;
				aa++;
				if (j == N - 1) {
					check = true;
				}
			}
		}

		if (start_value == 0) {
			ans += cal(2, temp_count - 1) - 1;
			ans %= MOD;
		}
		if (check) {
			ans += count;
			ans %= MOD;
		}
	}

	printf("%lld", ans);

	return 0;
}

Compilation message

UV.cpp: In function 'int main()':
UV.cpp:17:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define sld(a) scanf("%lld", &a);
                                 ^
UV.cpp:48:2: note: in expansion of macro 'sld'
  sld(N);
  ^
UV.cpp:17:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define sld(a) scanf("%lld", &a);
                                 ^
UV.cpp:51:3: note: in expansion of macro 'sld'
   sld(temp);
   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1176 KB Output is correct
2 Correct 0 ms 1176 KB Output is correct
3 Correct 0 ms 1176 KB Output is correct
4 Correct 36 ms 1780 KB Output is correct
5 Correct 36 ms 1780 KB Output is correct
6 Correct 0 ms 1448 KB Output is correct
7 Incorrect 9 ms 1448 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1448 KB Output isn't correct
2 Halted 0 ms 0 KB -