Task: | Milestone Counter |
Sender: | Game of Nolife |
Submission time: | 2015-11-25 16:57:56 +0200 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.06 s | details |
#2 | ACCEPTED | 0.06 s | details |
#3 | ACCEPTED | 0.05 s | details |
#4 | ACCEPTED | 0.06 s | details |
#5 | ACCEPTED | 0.05 s | details |
#6 | ACCEPTED | 0.06 s | details |
Code
#include <bits/stdc++.h> #define F first #define S second using namespace std; typedef long long ll; typedef long double ld; ll t[1010]; ll x[1010]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n,m; cin>>m>>n; for (int i=0;i<m;i++){ cin>>t[i]; } for (int i=0;i<n;i++){ cin>>x[i]; } set<pair<ll, ll> > vv; vector<ll> v; for (int i=0;i+m<=n;i++){ pair<ll, ll> lol; lol.F=x[i+1]-x[i]; lol.S=t[1]-t[0]; ll g=__gcd(lol.F, lol.S); lol.F/=g; lol.S/=g; //cout<<lol.F<<" "<<lol.S<<endl; int f=0; for (int j=2;j<m;j++){ ll b=t[j]-t[j-1]; ll a=x[i+j]-x[i+j-1]; ll gg=__gcd(a, b); a/=gg; b/=gg; pair<ll, ll> tt={a, b}; if (tt!=lol){ //cout<<"fail "<<tt.F<<" "<<tt.S<<endl; f=1; break; } } if (f==0){ if (!vv.count(lol)){ vv.insert(lol); v.push_back(x[i+1]-x[i]); } } } cout<<v.size()<<endl; sort(v.begin(), v.end()); for (ll ttt:v){ cout<<ttt<<" "; } 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... |