Submission #23780387
Source Code Expand
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
void solve(){
int n;
cin >> n;
vector<ll> a(n);
for(auto&i:a) cin >> i;
auto dp = vector(n+1, vector<modint1000000007>(n+1));
auto b = vector(n+1, vector(n+1,-1));
b[1][0] = 0;
dp[0][0] = 1;
ll s{};
for(int i{};i<(n);++i){
s+=a[i];
for(int j{1};j<=n;++j){
if(b[j][s%j]!=-1){
dp[i+1][j] = dp[b[j][s%j]][j] + dp[b[j][s%j]][j-1];
}
b[j][s%j] = i+1;
}
}
modint1000000007 ans;
for(int j{1};j<=(n);++j){
ans += dp[n][j];
}
cout << ans.val() << endl;
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
solve();
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Mod i |
| User | Motsu_xe |
| Language | C++ (GCC 9.2.1) |
| Score | 500 |
| Code Size | 1009 Byte |
| Status | AC |
| Exec Time | 533 ms |
| Memory | 73992 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example0.txt, example1.txt, example2.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, example0.txt, example1.txt, example2.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | AC | 11 ms | 3616 KiB |
| 001.txt | AC | 2 ms | 3580 KiB |
| 002.txt | AC | 2 ms | 3520 KiB |
| 003.txt | AC | 505 ms | 73992 KiB |
| 004.txt | AC | 512 ms | 73892 KiB |
| 005.txt | AC | 533 ms | 73636 KiB |
| 006.txt | AC | 501 ms | 73688 KiB |
| 007.txt | AC | 110 ms | 25048 KiB |
| 008.txt | AC | 435 ms | 64720 KiB |
| 009.txt | AC | 3 ms | 3920 KiB |
| 010.txt | AC | 505 ms | 73948 KiB |
| 011.txt | AC | 495 ms | 73916 KiB |
| 012.txt | AC | 505 ms | 73940 KiB |
| 013.txt | AC | 527 ms | 73816 KiB |
| 014.txt | AC | 472 ms | 73960 KiB |
| 015.txt | AC | 449 ms | 73988 KiB |
| 016.txt | AC | 101 ms | 25148 KiB |
| 017.txt | AC | 240 ms | 73808 KiB |
| 018.txt | AC | 407 ms | 73948 KiB |
| 019.txt | AC | 2 ms | 3624 KiB |
| 020.txt | AC | 2 ms | 3584 KiB |
| 021.txt | AC | 387 ms | 73956 KiB |
| 022.txt | AC | 409 ms | 73812 KiB |
| 023.txt | AC | 382 ms | 73972 KiB |
| 024.txt | AC | 384 ms | 73920 KiB |
| 025.txt | AC | 428 ms | 73832 KiB |
| 026.txt | AC | 442 ms | 73940 KiB |
| 027.txt | AC | 368 ms | 73960 KiB |
| example0.txt | AC | 2 ms | 3660 KiB |
| example1.txt | AC | 2 ms | 3620 KiB |
| example2.txt | AC | 3 ms | 3616 KiB |