online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include<bits/stdc++.h> #define ll long long using namespace std; const ll mod = 1000000007; vector<ll> a(200005),b(200005),mul(11); unordered_map <ll,ll> hsh[11]; ll getlen(ll a) { ll count = 0; while(a) { count++; a/=10; } return count; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n,k,ans = 0; cin>>n>>k; for(ll i=0;i<n;i++) { cin>>a[i]; b[i] = getlen(a[i]); a[i]=a[i]%k; hsh[b[i]][a[i]]++; } mul[0]=1; for(int i=1;i<=10;i++) { mul[i]=(mul[i-1]*10)%k; } for(ll i=0;i<n;i++) { for(ll j=1;j<=10;j++) { ll temp = (k - (a[i]*mul[j])%k)%k; hsh[b[i]][a[i]]--; ans = ans + hsh[j][temp]; hsh[b[i]][a[i]]++; } } cout<<ans<<"\n"; return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue