Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream in("puzzle.in");
- ofstream out("puzzle.out");
- int v[100001],vf[100001];
- int nrcif(int n)
- {
- int cnt=0;
- while(n)
- {
- n/=10;
- cnt++;
- }
- return cnt;
- }
- int main()
- {
- int n,i;
- in>>n;
- for(i=1; i<=n; i++)
- {
- in>>v[i];
- vf[v[i]]++;
- }
- int x=nrcif(v[1]),nr=1;
- for(i=1; i<x; i++)
- nr=nr*10+1;
- long long rez=0;
- for(i=1; i<=n; i++)
- {
- int ci=v[i],maxcif=0;
- while(ci)
- {
- maxcif=max(maxcif,ci%10);
- ci/=10;
- }
- for(int s=maxcif+1; s<=9; s++)
- if(s*nr-v[i]!=v[i])
- rez+=vf[s*nr-v[i]];
- else
- rez+=vf[s*nr-v[i]]-1;
- }
- out<<rez/2;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement