Task: | Milestone Counter |
Sender: | OOliOO_slayer |
Submission time: | 2015-11-25 20:51:40 +0200 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.05 s | details |
#2 | ACCEPTED | 0.05 s | details |
#3 | ACCEPTED | 0.05 s | details |
#4 | ACCEPTED | 0.06 s | details |
#5 | ACCEPTED | 0.04 s | details |
#6 | ACCEPTED | 0.05 s | details |
Code
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <map> #include <sstream> #include <utility> #include <set> #include <iomanip> using namespace std; typedef __int128 LL; int main(){ cin.tie(0); ios_base::sync_with_stdio(0); long long m,n; cin >> m >> n; vector<LL> p; vector<LL> s; for(LL i = 0; i < m; i++){ long long x; cin >> x; p.push_back(x); } for(LL i = 0; i < n; i++){ long long x; cin >> x; s.push_back(x); } LL k = p.size(); vector<LL> ans; for(LL start = 0; start < n; start++){ if(start + k - 1 >= n) break; LL A = s[start+1] - s[start]; LL B = p[1] - p[0]; bool good = true; for(LL i = 1; i < k; i++){ if(A*(p[i] - p[i-1]) != B*(s[start+i]-s[start+i-1])) good = false; } if(good) ans.push_back(A); } set<LL> distinct(ans.begin(), ans.end()); cout << distinct.size() << endl; for(auto x : distinct) cout << (long long)x << " "; cout << endl; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
17 47 100 101 102 104 110 116 128 16... |
correct output |
---|
11 1 6 36 216 1296 7776 46656 279... |
user output |
---|
11 1 6 36 216 1296 7776 46656 279... |
Test 2
Verdict: ACCEPTED
input |
---|
500 1000 100 102 104 106 108 110 112 11... |
correct output |
---|
1 2 |
user output |
---|
1 2 |
Test 3
Verdict: ACCEPTED
input |
---|
12 40 1 2 4 8 16 32 64 128 256 512 1... |
correct output |
---|
18 1 8192 16384 32768 65536 13107... |
user output |
---|
18 1 8192 16384 32768 65536 13107... |
Test 4
Verdict: ACCEPTED
input |
---|
2 1000 131345678912349 23234567891234... |
correct output |
---|
999 3 5 7 9 11 13 15 17 19 21 23 2... |
user output |
---|
999 3 5 7 9 11 13 15 17 19 21 23 2... |
Test 5
Verdict: ACCEPTED
input |
---|
22 102 100 101 102 104 106 110 114 12... |
correct output |
---|
0 |
user output |
---|
0 |
Test 6
Verdict: ACCEPTED
input |
---|
22 52 100 101 102 104 106 110 114 12... |
correct output |
---|
16 1 2 4 8 16 32 64 128 256 512 1... |
user output |
---|
16 1 2 4 8 16 32 64 128 256 512 1... |