Submission #22545

# Submission time Handle Problem Language Result Execution time Memory
22545 2017-04-30T05:27:03 Z 크리님 제가 귀여우면 됬지 뭘 더 원하세요 진짜(#952, sys7961, hyorothy, skdudn321) Unifying Values (KRIII5_UV) C++14
0 / 7
9 ms 1448 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);
		lli count = 1;
		bool check = false;
		lli cur = 0;
		lli temp_count = 1;
		for (int j = i + 1; j < N; j++) {
			cur += ve[j];
			if (cur == 0) {
				temp_count++;
			}
			else if (cur == start_value) {
				count *= temp_count;
				temp_count = 1;
				cur = 0;
				if (j == N - 1) {
					check = true;
				}
			}
		}
		if (start_value == 0) {
			ans += cal(2, temp_count);
			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);
   ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1176 KB Output is correct
2 Correct 0 ms 1176 KB Output is correct
3 Incorrect 0 ms 1176 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1448 KB Output isn't correct
2 Halted 0 ms 0 KB -