Submission #22682

# Submission time Handle Problem Language Result Execution time Memory
22682 2017-04-30T06:30:05 Z 현우야 이거 플로우야(#903, waylight3, pinebananais, ae04071) Unifying Values (KRIII5_UV) C++11
0 / 7
500 ms 1312 KB
#include <stdio.h>

typedef long long lli;
const lli mod=1e9+7;
int n;
lli sum[10001];
int chk[10001];
lli cnt[10001];

lli pow(lli a, lli p) {
	lli res=1;
	while(p) {
		if(p&1) res=(res*a)%mod;
		a=(a*a)%mod;
		p>>=1;
	}
	return res;
}

int main() {
	lli zsum=0;

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

	lli res=0;
	for(int i=1;i<n;i++) {
		if(sum[i]==0) {
			--zsum;
			if(sum[n]!=0) continue;
			res=(res+pow(2,zsum))%mod;
		}
		else {
			cnt[1]=1; chk[1]=i;
			for(int j=i+1;j<=n;j++) {
				if((sum[j]>0&&sum[i]>0||sum[j]<0&&sum[i]<0)&&sum[j]%sum[i]==0) {
					lli k=sum[j]/sum[i];
					if(k>n||k==1) continue;
					if(chk[k-1]!=i) continue;
					if(chk[k]!=i) {
						chk[k]=i;
						cnt[k]=0;
					}
					cnt[k]+=cnt[k-1];

					if(j==n) {
						res=(res+cnt[k])%mod;
					}
				}
			}
		}
	}

	printf("%lld\n",res);

	return 0;
}

Compilation message

UV.cpp: In function 'int main()':
UV.cpp:41:17: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     if((sum[j]>0&&sum[i]>0||sum[j]<0&&sum[i]<0)&&sum[j]%sum[i]==0) {
                 ^
UV.cpp:23:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
UV.cpp:25:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",sum+i);
                      ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1312 KB Output is correct
2 Correct 0 ms 1312 KB Output is correct
3 Correct 0 ms 1312 KB Output is correct
4 Execution timed out 500 ms 1312 KB Execution timed out
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 500 ms 1312 KB Execution timed out
2 Halted 0 ms 0 KB -