제출 #22542

#제출 시각아이디문제언어결과실행 시간메모리
225422000/4000 (#40)Unifying Values (KRIII5_UV)C++14
0 / 7
59 ms1992 KiB
#include <cstdio> #include <map> using namespace std; const int MAXN = 10004; const int P = 1000 * 1000 * 1000 + 7; typedef long long lli; int N; lli S[MAXN]; lli D[MAXN]; map<lli,int> dp; int main() { scanf("%d", &N); for (int i = 1; i <= N; ++i) { scanf("%lld", &D[i]); S[i] += S[i - 1] + D[i]; } int cnt = 0; for (int i = 1; i < N; ++i) { // 1 ~ i const lli st = S[i] - S[0]; if (st == 0 || S[N] % st != 0) continue; dp.clear(); dp[S[N]] = 1; for (int j = N - 1; j > i; --j) { auto it = dp.find(S[j] + st); if (it == dp.end()) continue; else dp[S[j]] = (dp[S[j]] + it->second) % P; } cnt = (cnt + dp[S[i] + st]) % P; } printf("%d\n", cnt); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

UV.cpp: In function 'int main()':
UV.cpp:16:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
                 ^
UV.cpp:18:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &D[i]);
                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...